🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Weird problem with prefab position and rotation

Started by
0 comments, last by KazYamof 8 years, 9 months ago

Im facing a weird problem when trying to set an instantiated GameObject position and rotation: its locked to (0,0,0). The object is instantiated from a prefab containing only the skeleton and an animator component. I have to use the following code to instantiate it:


GameObject playerPrefab = Resources.Load("Characters/test") as GameObject;
player = Instantiate (playerPrefab) as GameObject;

If I use player = Instantiate (playerPrefab, Vector3.zero, Quaternion.identity) as GameObject; the GameObject is locked at (0,0,0) and it cant be moved to any location, not by navmesh agent, or by directly setting transform.position.

If the first method works, whats the problem? Well, the problem is that I need to manually correct the rotation. The prefab automatically gets a (-90,0,0) rotation when I add the skeleton, which lays the character horizontally when I add the rest of the meshes. No matter how I instantiate the object, I cant rotate it. I have tried setting it with player.transform.rotation = Quaternion.identity; and also with player.transform.localRotation = Quaternion.identity; none of them works. Also trying setting the rotaiton in the prefab, but again, the mesh position gets locked at (0,0,0).

Does somebody has an idea about whats happening here?

Advertisement

There is no animation (or Update() code) automatically being played and putting the prefab always on position 0,0,0 and rotation -90,0,0?

This topic is closed to new replies.

Advertisement