Discuss Scratch

MrR0g3rs
New Scratcher
9 posts

Help with homing missile

I am adding some layers to my game. One will be that you will collect powerups to enable a “homing missile weapon”. When fired the missile is supposed to go to the nearest dragon. A couple of issues, the first is that I want the missile to flu to the target point first, but sometimes it will fly sideways, the second is that sometimes there is a delay between the button press and the missile launch. Am I on the right track with the homing code? I have been looking at lots of examples.

Game link: https://scratch.mit.edu/projects/94310026/

Press Z to launch the missile.
alberto85
Scratcher
14 posts

Help with homing missile

To make it point the right way you should rotate the image in the sprite editor so that it points to the right.
MrR0g3rs
New Scratcher
9 posts

Help with homing missile

Thanks for that tip. Now it is flying straight but not homing. Out of curiosity why does rotating it make a difference? Is it because I used the
pointindirection
block?
footsocktoe
Scratcher
1000+ posts

Help with homing missile

MrR0g3rs wrote:

Thanks for that tip. Now it is flying straight but not homing. Out of curiosity why does rotating it make a difference? Is it because I used the
pointindirection
block?


Yes. When you use a MOVE block, it moves the sprite in its DIRECTION. If you don't draw the sprite facing right, then how it looks and how it moves will not match.
CapeMan1008
Scratcher
98 posts

Help with homing missile

If you want to make it home in on a target, and not fly straight, start by making sure you have this setup:
repeatuntil...pointindirection. . .
And not this:
pointindirectionrepeatuntil.... . .
ScratchCatHELLO
Scratcher
1000+ posts

Help with homing missile

CapeMan1008 wrote:

If you want to make it home in on a target, and not fly straight, start by making sure you have this setup:
repeatuntil...pointindirection. . .
And not this:
pointindirectionrepeatuntil.... . .

This post is 4 years old.
malikfunderburk
Scratcher
5 posts

Help with homing missile

this is an old post
Oumuamua
Scratcher
1000+ posts

Help with homing missile

malikfunderburk wrote:

this is an old post

Do not spam, dear spammer. Thanks.
wosdcs
Scratcher
100+ posts

Help with homing missile

The best thing taht you can do, is have the missile save to a list, all of the distances to all dragons, and pick the dragon that is closest, from there, just setv the program to point towards that dragon and move # of steps.
wosdcs
Scratcher
100+ posts

Help with homing missile

The best thing taht you can do, is have the missile save to a list, all of the distances to all dragons, and pick the dragon that is closest, from there, just setv the program to point towards that dragon and move # of steps. OH! and make it in the editor face RIGHT!
ScratchCatHELLO
Scratcher
1000+ posts

Help with homing missile

wosdcs wrote:

-snap-

this topic is 5 years old and the OP left
CapeMan1008
Scratcher
98 posts

Help with homing missile

ScratchCatHELLO wrote:

CapeMan1008 wrote:

If you want to make it home in on a target, and not fly straight, start by making sure you have this setup:
repeatuntil...pointindirection. . .
And not this:
pointindirectionrepeatuntil.... . .

This post is 4 years old.

I'm sorry, I never check the dates on these things.
Harakou
Scratcher
1000+ posts

Help with homing missile

Thanks to everyone for offering your help, but this thread is pretty old - I don't think it's relevant anymore. When you respond to a topic, please make sure it's recent and the original poster still needs an answer. And if someone does necropost, please report it so that we can close the topic. Otherwise it just keeps happening. Thanks!

Powered by DjangoBB