hi i have a question i get an error if i want to instantiate a rigidbody object just like shooting something
the bullet i shoot is a rigidbody and i apply force to it but i get errors
this is the code
as you can see the bullet1 is a transform variable normaly on the top of the script.
the spawnPoint1 is in front of my players arm for shooting
but i get an error on the second line
this is the error
BCE0019: ‘rigidbody’ is not a member of ‘UnityEngine.Object’.
what should i do???
eriQue
January 6, 2011, 6:54am
2
Duck Typing is not supported on mobiles (docs ). Use #pragma strict and cast the instantiated object to a resulting type before assigning it to the var Bullet .
hi i figure out how to instantiate but now i want to add force to it but i keep getting that this error
NullReferenceException: Object reference not set to an instance of an object
heres my code
var bulletPrefabs : Transform;
var spawnPoint : GameObject;
// in the update function
var bulletforce : GameObject = Instantiate(bulletPrefabs, spawnPoint.transform.position, spawnPoint.transform.rotation) as GameObject;
bulletforce.rigidbody.AddForce (transform.forward * 2000);
i get the error on the bulletforce.rigidbody
can someone please help me a bit i keep trying
it spawns a bullet but the force wont work
thanks for reading and i hope for a awnser greets dr-mad
You must add Physics > Rigidbody to prefab ‘bulletPrefabs’