Reputation: 593
I have a zombie. When he dies, he should spawn a shotgun munition package, which the player can collect.
I want the rotation of the shotgunMunition to be 0, 0, 0.
So i used Quaternion.identity, but the munition gets always spawned with the rotation of the zombie.
This is my code:
Instantiate(shotgunMuni, transform.position, Quaternion.identity);
What i tried yet:
trying to use "Quaternion.Euler(new Vector3(0,0,0)) instead - didn't work, same result.
Google for a solution, but mostly they write "use Quaternion.identity" - i am using it..
Upvotes: 0
Views: 2885
Reputation: 51
If shotgunMuni is a child of a rotated object a rotation of zero will have it rotated to it's parents rotation. In your case it might be a child of zombie and therefore rotated. I can think of three ways to get your ammunition spawned with zero rotation.
Set the global rotation after instantiating your object.
GameObject shotgunMuniInstance = Instantiate(shotgunMuni, transform.position, Quaternion.identity);
shotgunMuniInstance.eulerAngles = Vector3.zero; // This is in global space
Rotate the child object by the negative rotation of it's parent.
Have a seperate transform as a parent for your ammunition which has zero rotation.
Upvotes: 2