Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Targeting?
- BilboUnicorn
- Scratcher
26 posts
Targeting?
So what I am trying to do is have a laser target a specific sprite, destroy it, then move on to another. And it can't just be going after ANY sprite. Here's an attempt of an example. N is the must-not-be-destroyed item, L is the laser that must be ‘heat seaking’, and T are the three targets that it needs to go after based on which ones are closest. Any ideas?
N L
T
T
T
N L
T
T
T
- drmcw
- Scratcher
1000+ posts
Targeting?
Search for tower defense games they do that and I think scubajerry has a few good examples of this.. You just need to store the distance of each target, find the smallest and target that. If the targets are sprites then use the distance to block. If they are clones then you'll need to store the x,y positions and/or distance to laser in a list anyway.
Last edited by drmcw (Oct. 25, 2013 06:38:42)
- BilboUnicorn
- Scratcher
26 posts
Targeting?
this.. You just need to store the distance of each target, find the smallest and target that. If the targets are sprites then use the distance to block. If they are clones then you'll need to store the x,y positions and/or distance to laser in a list anyway.Thanks, that's exactly what I needed! Search for tower defense games they do that and I think scubajerry has a few good examples of
- scubajerry
- Scratcher
1000+ posts
Targeting?
this.. You just need to store the distance of each target, find the smallest and target that. If the targets are sprites then use the distance to block. If they are clones then you'll need to store the x,y positions and/or distance to laser in a list anyway.Search for tower defense games they do that and I think scubajerry has a few good examples of
That was my first try. This one is more general purpose.
- Discussion Forums
- » Help with Scripts
- » Targeting?