Hi. I making a 2D rpg game. I need enemy health bar to instantiate over the enemy and follow it. I create a prefab of canvas with the bar. Canvas is set to World Space. But when bar instantiates, it starts to strangely flying everywhere. It follows enemy, but not in the right way. Here is a line of code that follows the enemy:
void Update () { gameObject.transform.GetChild (0).transform.position = enemy.transform.position + new Vector3 (0, enemy.transform.position.y + 1f, 0); }
Yes, its kinda messy, but pls help me someone. Thanks.