I have a script that worked in one project; however, porting over to another project has been problematic. Basically, I have a fighter with two weapon points on each wing. Firing guns should fire both weapons. This is the code that worked in one project but failed to work in the new project:
rBulletR = Instantiate(oBullet) as Rigidbody; rBulletR.transform.position = oPositionR.transform.position; rBulletR.velocity = oShip.transform.TransformDirection(Vector3.forward * (500f + vVelocity));
I’ve only added one gun in the example. The other gun basically has a L instead of R. oPositionR is declared in as a public GameObject with the spawnpoint dragged into the field. oBullet is the bullet rigidbody. And oShip is the actual plane. It is a publicly declared Gameobject with the plane dragged into the field.
The error I get is:
NullReferenceException: Object reference not set to an instance of an object
FireControl.FireGuns () (at Assets/Battlestar Assets/Updated Scripts/FireControl.cs:139)