Y Axis rotation is increasing too fast
Hey. I have a gun and a bulletEmitter (empty gameObject). The bulletEmitter is a child of the gun. It is located at the front of the barrel. If i rotate the gun the bulletEmitter stays infront of the barrel (as it should). I instantiate my Bullets with this code: (global variables: bullet prefab and the bulletEmitter.
void Update () {
if (Input.GetKey(KeyCode.Mouse0))
{
GameObject tmpBulletHandler;
tmpBulletHandler = Instantiate(bulletPrefab, bulletEmitter.transform.position, bulletEmitter.transform.rotation) as GameObject;
tmpBulletHandler.transform.Rotate(Vector3.left * 180);
Destroy(tmpBulletHandler, 10.0f);
}
}
But for some reason the bullets are spawning very offset (only in the y rot axis)when the gun is rotating on the y axis (even though the emitter is staying where it should!)
This only happens when i set the public variables in the inspector before i go into "play". When i assign the Prefab while in "play" it works fine.
Your answer
Follow this Question
Related Questions
How can i add knockback to the player when firing my shotgun? (3d) 0 Answers
Firing bullets ( Tnx for the help ) 1 Answer
MY effect dont destroy 0 Answers
How do you make bullet Spread? 0 Answers
Unity 2d simple c# shooting script 1 Answer