- Home /
Rotation on prefab will not change. Help.
I have a prefab that has a rotation of 90 degrees on it so it should be horizontal. If I instantiate this prefab using Quaternion.Identity it comes out vertical and isn't keeping the rotation.
I've tried everything I can think of and google but these prefabs WILL NOT ROTATE and it's driving me nuts.
Here's my instantiation:
Instantiate(myWires[x], new Vector3((float)(ranges[x] - 1.40) + y, 18.5f, x * 20), myWires[0].transform.rotation);
Note I've changed it from Quaternion.Identity here in hopes it would stay at 90 degrees but nope. What gives? Why will these prefabs not rotate or keep their native rotation?
I never had a problem with rotation. However, identity rotation is (0,0,0). And this is what you got.
About your code posted here. I cant help you since i dont know what myWires[x] is.
Are you overriding / setting the rotation somewhere else? I had the same problem in the Angry Bots demo as the player rotation is reset in the movement controller.
myWires[x] is just a GameObject array that holds my wire prefabs.
Answer by MountDoomTeam · Jan 30, 2013 at 11:25 AM
try setting the rotation with a line after the Instantiate,
var mywires = Instantiate (etc...);
mywires.eulerAngles = Vector3(0, 0, 0);
if that doesn't do it, it means that the wire is being told to flip somewhere else in the code
That didn't do it either, so I'll look over and post my other code after I get some time.
Your answer