move around bullit prefab

hi everyone,
i have the script, move around. and, with the videos of TornadoTwins,
i learn how put the bullit prefab in the script, but i don’t know the button to
shot the bullit, and i want to know if its possible know the button seeing the script

here it is
but appear this error:

NullReferenceException
MoveAround.Update () (at Assets/Scripts/Mouse Scripts/MoveAround.js:26)

(I dont know how put the script in the window like the others in forum)

var speed = 3.0;
var rotateSpeed = 3.0;
var bullitPrefab:Transform;
private var dead = false;

function OnControllerColliderHit(hit : ControllerColliderHit)
{
if(hit.gameObject.tag == “fallout”)
{
dead = true;
}
}

function Update ()
{
var controller : CharacterController = GetComponent (CharacterController);
transform.Rotate (0, Input.GetAxis (“Horizontal”) * rotateSpeed, 0);

var forward = transform. TransformDirection(Vector3.forward);
var curSpeed = speed * Input.GetAxis (“Vertical”);

controller.SimpleMove (forward * curSpeed);

if(Input.GetButtonDown(“Jump”))
{
var bullit = Instantiate(bullitPrefab,
GameObject.Find(“spawnPoint”).transform.position,
Quaternion.identity);
bullit.rigidbody.AddForce(transform.forward * 2000);
}
}

function LateUpdate()
{
if(dead)
{
transform.position = Vector3(0,4,0);
gameObject.Find(“Main Camera”).transform.position = Vector3(0,4,-10);
dead = false;
}
}

@script RequireComponent(CharacterController)

thanks

Broken English can be very hard to understand sometimes.

The error is probably where you either don’t have an object assigned to your bullitPrefab variable. or, you don’t have an object named “spawnPoint” in your game.

To find the error, double click on it, and it will open the editor and put your cursor on the offending line.

Using the Worm game from the Tornado Twins is a great start. I think you are a little lost as you may have copied the code instead of typing it yourself. :wink:

This is the part of the code that tells you that you are firing:

if(Input.GetButtonDown("Jump"))
{
var bullit = Instantiate(bullitPrefab,
GameObject.Find("spawnPoint").transform.position,
Quaternion.identity);
bullit.rigidbody.AddForce(transform.forward * 2000);
}
}

It starts off with If(you pressed the Jump key), if this is still the default key, it is a space bar. so your Jump key is your space bar.

thanks

but, the problem still

That doesn’t tell us if you double clicked on the error to find the line that is causing it. :wink:

YES, I know which line, but I dont know solve the problem…

And… Which line is it?

line 26:

var bullit = Instantiate(bullitPrefab,

Gotta love the tornadotwins.

Assets/MoveAround.js(30,17): BCE0144: ‘UnityEngine.Component.rigidbody’ is obsolete. Property rigidbody has been deprecated. Use GetComponent() instead. (UnityUpgradable)

it show me this error I am programming in Javascript