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);
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."
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
To help users post good questions and use the site effectively we have posted a user guide. Please check it out.
Answers and Comments
No one has followed this question yet.
object Pass through the polySurface Maya imported scene.
Problem with array on gameobjects
What is a SIGBUS in unity iphone and why does it happen so often?
Object Reference Required to access non-static member 'UnityEngine.RigidBody.AddRelativeTorque'
Extend the Collider When Picking Up Objects