Hello, I’ve been using unity for a while, and I know basic scripting, although I’m still learning. I know that I’m going to get yelled at to go watch tutorials and whatnot, and to learn scripting, but I need a quick answer. I just want to complete the shooting and guns and core of the game, so I can focus on the story. All the tutorials I’ve watched make the bullet spawn at the wrong place, and they’re all to complicated for such a simple thing. Below is the code for another Unity answer, but I get an error: Not a valid Identifier: ‘nBullate’.
var bullet : GameObject;
var spawnPoint : Transform;
function Update () {
if(Input.GetKeyDown("mouse0")) {
var nBullet = Instantiate(bullet, spawnPoint.position, spawnPoint.rotation);
nBullate.rigidbody.velocity = spawnPoint.TransformDirection(Vector3(0,0,100));
}
}
Please help me. I understant everything in this script except for the nBullate part.
Thanks in advance!
You’ve misspelled ‘nBullet’ on line 7…you have an extra ‘a’ in the name. Plus on line 6, you need to add ‘as GameObject’:
var nBullet = Instantiate(bullet, spawnPoint.position, spawnPoint.rotation) as GameObject;