Heres my code. when i click the object isnt moving, just being created. the positioning of the creation is correct but the force thing isnt pushing it. when i click a second time it just creates another object. Why wont my object be pushed forward? Im working in Javascript
#pragma strict
public var StonePower : float;
public var TestStone : GameObject;
public var X = 24;
public var Y = 0.5;
public var Z = 0;
function Start () {
}
function OnGUI () {
GUI.Label (Rect (50, 25, 100, 30), "Power");
StonePower = GUI.VerticalSlider (Rect (25, 25, 100, 30), StonePower, 20.0, 0.0);
}
function Update () {
if(Input.GetButtonDown("Fire1")){
var pos = Vector3 (X, Y, Z);
Instantiate(TestStone, pos, Quaternion.identity);
TestStone.rigidbody.AddForce(transform.TransformDirection(Vector3.forward) * StonePower, ForceMode.Impulse);
}
}