Hello. I have a problem with rotation a simple prefab. I have following simple code:
var car = Instantiate(carPrefab, startMarker.Position, Quaternion.identity);
Quaternion initialRotation = car.transform.rotation;
car.transform.rotation = initialRotation * Quaternion.Euler(0, 180, 0);
Debug.Log("Car prefab angle: " + car.transform.rotation.eulerAngles);
In the console every time I create an gameobject from script I see:
Car prefab angle: (0.00, 180.00, 0.00).
But in the scene this instantiated game object 95% of time has rotation (0, 0, 0) and 5% of time (0, 180, 0). If I remove Rigidbody from car prefab, every time new car prefab is intantiated with (0, 180, 0) in the console and with (0, -180, 0) in the scene. Why doest it happen?
I tried to put a simple cube prefab into this script field as prefab to instantiate. This cube every time has right rotation (0, 180, 0) in the console and in the scene.