AI follow
by Richard Gillis · in Torque X 2D · 12/08/2007 (9:17 am) · 2 replies
Can someone please explane to me how you would have a sprite follow or go to a certain location that a target sprite or object is?
Also if the target changes location it will be able to follow to that location.
Thanks in advance.
Also if the target changes location it will be able to follow to that location.
Thanks in advance.
Associate John Kanalakis
EnvyGames
public void ProcessTick(Move move, float elapsed) { // determine angle to point to float angle = T2DVectorUtil.AngleFromTarget(_sceneObject.Position, _TargetObject.Position); // set the rotation _sceneObject.Rotation = angle; // move towards obejct _sceneObject.Physics.Velocity = T2DVectorUtil.VelocityFromTarget(_sceneObject.Position, _TargetObject.Position, _speed); return; }This is not a full code listing, but you can start with the MovementComponent as a reference.
John K.