- Home /
[Solved] Problem with rotation on an Instantiated Object
So i am instantiating a shield that goes over my enemy ship but the problem I'm seeing is that some of the shields are rotated how they are supposed to be but others are rotated about 15 degrees or so on the z axis. Cant figure out why some are rotating like this. I think somehow the enemy ship is affecting the rotation of the shield.
Here is the code for Instantiating the shields in the start function:
shieldInstance = (GameObject) Instantiate (enemyShield, offsetY, Quaternion.Euler (0,0,180));
shieldInstance.transform.parent = transform;
Thanks for any help
Im not too sure on that one, it seems accurate to me. What you could try is putting a script on your shields prefab (or use a script hats already on it), and add something to make sure its rotation is always at 180, something like: transform.rotation = Quaternion.Euler (0,0,180);
You could even try putting that after you set the parent, to ensure after its linked (cause it may take the parents rotation ins$$anonymous$$d of its own), its rotation is reset to 180. In fact, if you do that, you might want to use its local rotation ins$$anonymous$$d.
shieldInstance.transform.localRotation = Quaternion.Euler(0,0,180);
Thanks so much Dibbie, when i used the localRotation it worked great! Although some of them were off centered so i just fixed that with forcing it to where i want it with localPostition :)
Your answer
Follow this Question
Related Questions
w in Quaternion? 1 Answer
Bone Rotation on X (or any) axis Issues 1 Answer
Unity Rotate Raycast on Quaternion 1 Answer
how to rotate bullet towards target direction?unity2D 0 Answers