How to Get Consistent Sprite Tracking Speeds on Scratch
by Witheredboi in Circuits > Software
239 Views, 0 Favorites, 0 Comments
How to Get Consistent Sprite Tracking Speeds on Scratch
This mostly applies to things trying to kill you in any game you make.
I struggled with this for a while. What I mean by consistent tracking speed is making a sprite glide at the same speed towards a target, no matter the distance.
This, of course, uses the "glide to" block, but it took a little while to get the code right to get the desired effect, since it takes some manipulation to get right.
Supplies
Surprisingly Simple
This is actually a shockingly simple piece of code. It takes 3 blocks to do: one that identifies the target (glide to Warden), one that sets a level pixels-per-second speed (distance to Warden), and one to alter the speed (divided by 300). The higher the divisor, the faster the sprite moves (as seen when attacking the player after recieving a sculk signal).