- Home /
Question by
Nico 1 · Apr 05, 2011 at 07:35 PM ·
rigidbodyobjectiphonenullreferenceexception
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);
Comment
Answer by Eric5h5 · Apr 05, 2011 at 07:37 PM
Either you didn't assign anything to bulletPrefab, or else it's not finding SpawnBullet.
Sorry mate, i fixed it but... i have this: "InvalidCastException: Cannot cast from source type to destination type."
Your answer
![](https://koobas.hobune.stream/wayback/20220613120933im_/https://answers.unity.com/themes/thub/images/avi.jpg)