Monthly Archives: October 2011

Calculate angle from current heading to target object

If you want to have an object turn automatically towards a target then you have to find out in which direction to turn. The usual angle function just returns the smallest angle between the current heading and the heading towards the target but not which way around. Vector3 lTarget = transform.InverseTransformPoint(target.position); targetDistance = lTarget.magnitude; targetAngle [...]