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

Unable to set position of instantiated prefab

$
0
0
I have been combing the forums and debugging this for a while and am hoping someone here would kindly help me on this. I have Unity 2017.3.0f3 and am trying to instantiate an object, then set its position. Here's the code snippet. if (dead) { rb2d.velocity = (new Vector2(0, 0)); GameObject deathAnim = Instantiate(deathAnimation, new Vector3(3,3,0), transform.rotation); //deathAnim.transform.position = transform.position; Debug.Log(deathAnim.name + " " + deathAnim.transform.position + " " + transform.position); transform.position = startPosition; if (carrying) { DropObject(); } dead = false; } For some reason the clone always get's created at 0,0,0 and it won't move to the desired position I've tried: GameObject deathAnim = Instantiate(deathAnimation, new Vector3(3,3,0), transform.rotation); As well asGameObject deathAnim = Instantiate(deathAnimation); deathAnim.transform.position = transform.position; When I Debug.log the position of deathAnim, it has the correct position in the console. But when I pause the game and click on the deathAnim clone, the position in the inspector reads 0,0,0. This really confuses me. Pleas help, this is going to give me an aneurysm. (sorry for my terrible suck with markdown). ![alt text][1] [1]: /storage/temp/115361-2018-04-19-17-12-37-unity-201730f3-personal-64bit.png

Viewing all articles
Browse latest Browse all 508


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