Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Pen Flashlight..... Maybe?
- MPWreal
-
3 posts
Pen Flashlight..... Maybe?
Now, this may not make sense. I'm making a 2D top-down horror game and I need a flashlight. Simple, right? Well, it's not. I'm trying to create a cone of light that emits from the player and follows the mouse. I want the light to start small but slowly get bigger as it is farther away from the origin sprite as if in a cone-ish shape. How would I do this? I'm thinking I could have a simple Pen script that goes from one point to another gradually getting bigger until it reaches its final point. Like this.
- deck26
-
1000+ posts
Pen Flashlight..... Maybe?
Other projects have done this. This was something vaguely similar that I did https://scratch.mit.edu/projects/61593394/ - obviously you'd have to change the shape of the light being shone but it should be adaptable to suit your needs.
- MPWreal
-
3 posts
Pen Flashlight..... Maybe?
The problem with this is that I need something that can continuously change its shape to always be originating from its first point. I could change the shape, yes, but then it would just be a triangle gap that doesn't start at the player. Make sense? 

- deck26
-
1000+ posts
Pen Flashlight..... Maybe?
If you mean the light stops when it hits something then, yes, the shape keeps changing and you need to look at raycasting projects. Otherwise the shape doesn't change, it just rotates according to where the flashlight is being shone.
You can also make sure any obstacles are in front of the flashlight sprite so the light does appear to be stopped by them.
You can also make sure any obstacles are in front of the flashlight sprite so the light does appear to be stopped by them.
- MPWreal
-
3 posts
Pen Flashlight..... Maybe?

- gggoldgamer_returned
-
2 posts
Pen Flashlight..... Maybe?
then you make it follow the character like this a great example is my game im creating and here is the code in motion https://scratch.mit.edu/projects/762871505/
Last edited by gggoldgamer_returned (Nov. 29, 2022 01:48:38)
- TheWeeklyReader
-
100+ posts
Pen Flashlight..... Maybe?
Are you not able to just make the flashlight part of the player costume?
- Discussion Forums
- » Help with Scripts
-
» Pen Flashlight..... Maybe?