- Home /
bullet issue
got a bullet made and set up to a prefab and added to my main object but when space is pressed nothing happens any ideas
var bullet:Rigidbody;
if (Input.GetKeyDown("space")){
var tempbullet: Rigidbody;
tempbullet = Instantiate(bullet,transform.position,transform.rotation);`
I believe you can't instantiate a rigidboy. Ins$$anonymous$$d try to change the type to Transform;
sorry i do not understand change what type to transform ?
You can instantiate a rigidbody. I would say there's nothing wrong with your code - Except there's a missing '}', but that should throw an exception.
Don't you get any exceptions?
no i have included it just must of missed it off of here i cnt work out why its not working .. theres no error or anything
Answer by robhuhn · Oct 22, 2012 at 03:38 PM
The only thing I could imagine if everything is attached and assigned properly is that your snippet isn't within the Update method.
var bullet:Rigidbody;
function Update()
{
if (Input.GetKeyDown("space"))
{
var tempbullet: Rigidbody;
tempbullet = Instantiate(bullet,transform.position,transform.rotation);
}
}
Answer by ilovemypixels · Oct 22, 2012 at 05:15 PM
Yeah should be GameObject I guess. I also don't think you need the tempbullet variable.
Answer by scarfey91 · Oct 22, 2012 at 03:43 PM
nope it all in the right place im gonna have a friend go over the attchments and assigned stuff see what he thinks