Before updating to Windows 10 you may need to return your Pro license. More information here

NullReferenceException: Object reference not set to an instance of an object

Hi, I'm working on an iphone app and I have solved the problem of having the rigidbody not being part of UnityGameEngine.GameObject... but now I'm stuck with this... anyone able to help? my code right now is:

var bullet  = Instantiate(BulletPrefab,GameObject.Find("SpawnBullet").transform.position,Quaternion.identity) as GameObject;
bullet.rigidbody.AddForce(transform.forward * shootForce);

more ▼

asked Apr 05, 2011 at 07:35 PM

avatar image

Nico 1
5 9 6 10

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Either you didn't assign anything to bulletPrefab, or else it's not finding SpawnBullet.

more ▼

answered Apr 05, 2011 at 07:37 PM

avatar image

121k 80 365 774

Sorry mate, i fixed it but... i have this: "InvalidCastException: Cannot cast from source type to destination type."

Apr 05, 2011 at 07:54 PM Nico 1
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: Apr 05, 2011 at 07:35 PM

Seen: 1686 times

Last Updated: Apr 05, 2011 at 07:35 PM