How do I make a sprite go to the mouse, but stay in a grid, like in Coolstuff's Pathing AI?
Last edited by Sunrise-Moon (2010-07-15 17:21:05)
Offline
Ah, an example of mine! I love it when stuff like this happens.
(For those of you reading this - this script has been fixed! That's said below is no longer relevant )
go to x: ((round(((x position of mouse-pointer) / 30) - 0.5) * 30) y ((round(((y position of mouse-pointer) / 30) - 0.5) * 30)
You can change the 30s to however big you want your grid to be. Happy grid-ing!
Last edited by coolstuff (2010-07-24 17:04:15)
Offline
coolstuff wrote:
Ah, an example of mine! I love it when stuff like this happens.
Code:
go to x: (round(((x position of mouse-pointer) / 30) - 0.5) y (round(((y position of mouse-pointer) / 30) - 0.5)You can change the 30s to however big you want your grid to be. Happy grid-ing!
Cool, thanks
Edit: It isn't quite working. Mind putting it in block form and taking a pic of teh blockz?
Last edited by Sunrise-Moon (2010-07-15 18:06:49)
Offline
Sunrise-Moon wrote:
coolstuff wrote:
Ah, an example of mine! I love it when stuff like this happens.
Code:
go to x: (round(((x position of mouse-pointer) / 30) - 0.5) y (round(((y position of mouse-pointer) / 30) - 0.5)You can change the 30s to however big you want your grid to be. Happy grid-ing!
Cool, thanks
![]()
Edit: It isn't quite working. Mind putting it in block form and taking a pic of teh blockz?
Oops! Multiply the entirety of the blocks in the "x" and "y" spots by 30 and it should work like a charm. Unfortunately I cannot blockify it because I am on my iPod.
Offline
coolstuff wrote:
Sunrise-Moon wrote:
coolstuff wrote:
Ah, an example of mine! I love it when stuff like this happens.
Code:
go to x: (round(((x position of mouse-pointer) / 30) - 0.5) y (round(((y position of mouse-pointer) / 30) - 0.5)You can change the 30s to however big you want your grid to be. Happy grid-ing!
Cool, thanks
![]()
Edit: It isn't quite working. Mind putting it in block form and taking a pic of teh blockz?Oops! Multiply the entirety of the blocks in the "x" and "y" spots by 30 and it should work like a charm. Unfortunately I cannot blockify it because I am on my iPod.
Works now . Thanks!
Offline