- Home /
Rotating a Prefab?
hi im trying to rotate a prefab on X 90 but its not doing it ive tried using this
void Start ()
{
transform.Rotate(90, 0, 0);
}
but its not doing it my object is a piece of tetris looking like this watching it from top
___
| |
|___|
and i want it to look like this
__
| |
| |
| |
| |
| |
|__|
i have also tried modifying the prefab and i can modify scale but not rotation any help plz?
Answer by Jesse Anders · Apr 30, 2011 at 08:19 PM
Make sure you understand the difference between a prefab and a game object that's been instantiated (cloned) from that prefab.
With the above code, it's unlikely that you're actually 'rotating a prefab'. If however that script is attached to the prefab, then any game object cloned from the prefab should indeed be rotated 90 degrees as soon as its Start() function runs.
Keep in mind though that Start() only runs once, sometime before Update() is called for the first time. As such, in this case it'd probably make more sense simply to instantiate the game object with the desired orientation (rather than modifying it after the fact in the Start() function).
yeah... the thing is i cant really do that it wont let me modify the rotation of the imported asset :S and i tried using it on the Start Function because i only need it to rotate once in X and then do whatever else it needs to
Answer by Makenshi · Apr 30, 2011 at 08:45 PM
seems like initializing the rotation in 0 before implementing it on the Start did the job got no idea why but it worked tyvm for the help anyways
Answer by no00ob · Jan 16, 2018 at 06:25 PM
Thx a simple way to add this instead of 100 lines of code like the other ways ive seen, thx once more.