x


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 '11 at 07:35 PM

Nico 1 gravatar image

Nico 1
5 3 3 6

(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 '11 at 07:37 PM

Eric5h5 gravatar image

Eric5h5
102k 49 165 620

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

Apr 05 '11 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

By RSS:

Answers

Answers and Comments

Topics:

x2698
x2150
x1553
x618

asked: Apr 05 '11 at 07:35 PM

Seen: 1483 times

Last Updated: Apr 05 '11 at 07:35 PM