AddRelitiveForce Problems


I am shooting a bullet from my car. I have this script:

 var BulletPrefab:Transform;
    var force : float = 2000;
    //var canShoot:boolean = true;
    function FixedUpdate()
    		var bullet = Instantiate(BulletPrefab,transform.position,Quaternion.Euler(90,0,0));
d    		bullet.rigidbody.AddRelativeForce(Vector3(0, 0, 1) * force);
    	//	Debug.Log("Relitave force");
    //		Physics.IgnoreCollision( bullet.collider,transform.root.collider );

And attatched it to two children of my car object, BulletL and BulletR. Even when I try changing the Vector and such, the bullet still shoots on the Z axis.

How do I fix this?

Here’s your problem: Quaternion.Euler(90,0,0)

You may want to use this, instead: transform.rotation

Reason being, the value you’re passing now is a static rotation. It won’t vary, ever, no matter which way your shooter is facing. You probably want to reference the shooter’s facing and/or target when creating the bullet’s rotation.