Game Development Community

How to get a sprite to "look at" another one?

by Steve Bisson · in Torque Game Builder · 05/11/2006 (11:36 am) · 1 replies

I am trying to have the enemies face my player and move toward it. I kinda achieved chassing the player but facing the player no matter where it is on the screen is still a mistery.

i am working on this boss character and it doest make sense if its not facing the player at all time.

Heres a video of it.
www.dakurv.com/temp/boss_movie.wmv

How can i make it face the player at all time?

#1
05/11/2006 (11:48 am)
You can use, t2dAngleBetween(%this.sprite.getPosition(), $player.getPosition()) to find the angle between the two, and set the rotation of the enemy accordingly, Probably more suitable would be to use that angle to call the rotate to function.

%this.sprite.rotateTo(t2dAngleBetween(%this.sprite.getPosition(), $player.getPosition()), 600); [600 is the speed of rotation]