I have a 3D plane with "enemies", each one havehas it's canvas with a health bar, that follows the enemy position. When the enemy rotaterotates, the health bar position gets laggedlaggy and jittery (you see no fluently, like a jump)
The code that I'm using is:
private Camera _camera;
private RectTransform _healthBarReact;
void Start {
_camera = GameObject.Find("Camera").GetComponent<Camera>();
_healthBarReact = transform.FindChild("HealthBarImage").GetComponent<RectTransform>();
}
void Update {
Vector3 screenPoint = _camera.WorldToScreenPoint(transform.parent.position); // the parent is the enemy, I attached the script to the child canvas "HealthBar"
_healthBarReact.position = screenPoint;
}
How can I fix that "lag" issue? apparently, the issue only occurs when the enemy is rotating... when it follows you in a straight line, the healthbar looks well.