Hi all,
In my app I have code which works out the angle between two points (“critter” and “food”) so that critter can move in a direct straight line towards the food.
local angle = math.atan2(food.y-critter.y ,food.x-critter.x)
critter.x = critter.x + (math.cos(angle) \* speed)
critter.y = critter.y + (math.sin(angle) \* speed)
Now, as I understand it, the object.rotation command will rotate an object by x degrees not a specific angle. How can I get it so that the critter faces the food directly so he is always looking in the direction he is travelling?
I’ve tried various methods but they either throw up an error or just don’t do anything and I can’t figure out if I’m missing something really easy.
Cheers [import]uid: 7841 topic_id: 13498 reply_id: 313498[/import]
