Hi all, i try to do my first shoot but i have one problem (I am new in Unity3D).
i Have this code:
public var puntoDisparo: Transform;
public var bala: GameObject;
public var velocidad: float = 10;
function Update () {
if(Input.GetButtonDown("Fire1")){
var cloneBala : GameObject = Instantiate (bala, puntoDisparo.position, Camera.main.transform.rotation);
cloneBala.rigidbody.AddForce(new Vector3(0,0,velocidad), ForceMode.velocityChange);
}
}
Before add this line cloneBala.rigidbody.AddForce(new Vector3(0,0,velocidad), ForceMode.velocityChange);
When i clic on left button mouse my gameObject is perfectly duplicated but however when i try to do that this gameObject can move foward i have this error:
NullReferenceException: Object
reference not set to an instance of an
object Disparo.Update () (at
Assets/Scripts/Disparo.js:15)
‘Disparo’ is the script that i show before… So… What happend? my gameObject only move when i push it with others gameObjects (same gameObjects)
Here some pics… In the Screen Shot UnityShoot you can see that only when i clicked 3 times if when one gameobject fly!
Please Help i want to keep learning
ScreenShots 125125
http://www.dropbox.com/gallery/45494271/1/Screen%20Shots%20Unity3D%20FPS?h=317b52