Like, shooting a projectile that always aims at the player? Tried doing this, but it just shoots weirdly and doesn’t work.
Something something Pythagorean theorem.
If you make the y speed the y distance between the shooter and the… recipient? And the same with the X, then the projectile will work. You might have to mess with - and +, it has been a while since I have done this. I will go look at old code if you need a better explanation and a few screenshots.
Actually, I think there is a way easier way to do this. After looking at my old code, I actually gave up on the math and used the Follow ( ) with speed () block on a temporary invisible sprite. Then I set two variables to the X and the Y speed of the invisible object, deleted the invisible object, and then set the bullet’s X and Y speed to the two variables from before. Hope this helps!
The arcade-sprite-util
extension has blocks to help you do that:
could you give me an example?
Of course! Here is the simple way I was talking about. The main thing to note is the Wait 100 block after setting the sprite to follow. This gives the sprite time to start following the player sprite and you will notice that even with a Wait 50 there instead the sprites will often be slightly off of where they should be going. If this wait is not desirable you can just use the Sprite Util extension talked about above!
thank you so much! i tried the Pythaga-somthing theorem technique though,
Did you figure it out? I’ve always been too lazy to do the math and stuff, but I suppose once you do it once it can be copied between projects so I’m very interested if you did get it working!
i did