Question by
Tudvari · Mar 29, 2020 at 02:47 PM ·
scripting problemuicanvas
Health bars above enemies but for some reason while I move, they are offsetted.
Hi guys!
I started making Health Bars above enemies in my game made in Unity.
But for some reason, if I'm moving, it's offsetted in that direction.
The health bar is on an Overlay canvas, and contains basic images.
The parent:
The code is pretty simple, in FixedUpdate:
healthBar.transform.position = Camera.main.WorldToScreenPoint(target.position)
GIF: https://i.imgur.com/K8mwzTW.mp4
Any ideas? :D
Thanks in advance!
canvashelath.png
(11.7 kB)
Comment
Best Answer
Answer by Tudvari · Mar 29, 2020 at 02:54 PM
Fixed.
Instead of FixedUpdate, it should be in LateUpdate.