I’m trying to do a simple turret script, pointing my object toward another one on only one axis, and for this, I’m using Transform.InverseTransformPoint to get a localized position of my target.
The problem is when I use this function, the result position is all jiggy one frame after another.
An example script could be this :
using UnityEngine;
using System.Collections;
public class TurretControl : MonoBehaviour {
public Transform target;
// Update is called once per frame
void Update () {
Vector3 localizedPosition = transform.InverseTransformPoint(target.transform.position);
Debug.Log (string.Format ("Frame = {0}, position = {1}", Time.frameCount, localizedPosition));
}
}
The target object don’t move a bit, and the logs gives me this :