Quantcast
Channel: Questions in topic: "clone"
Viewing all articles
Browse latest Browse all 508

Moving a transform behaves odd

$
0
0
Working on a 2D game. So I have a Unit object prefab. The unit has a child object with a GUITexture (it's health bar) I move the health bar guitexture if the unit moves like so: public void LateUpdate () { // if(!isSelected) // return; _lbl.SetActive(isSelected); _pos = Camera.main.WorldToViewportPoint(transform.position); _pos.z = 0f; _pos.y = _pos.y+0.05f; _lbl.transform.position = _pos; } The _lbl is the child object that contains the health bar. When it was just a single object in the scene this worked perfectly. But whenever I instantiate a unit on runtime the health bar moves all jittery. Even if I drag a new object in the scene and save the scene the new object has the jitter. If i close unity and restart it and start the scene the new unit's health bar moves smooth again. Since all units need to be dynamically instantiated this is a problem. So to summarize: Original object works like a charm, Object (clone) has weird jitter. Any help with this conundrum would be greatly appreciated!

Viewing all articles
Browse latest Browse all 508

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>