Random.value not working?

I have this…

#pragma strict

var intYForce : int;
var intXForce : int;
var intZForce : int;
var d20 : Rigidbody;

function Update () {
	
	
	if(Input.GetButtonUp("Jump")){
	
		intXForce=Random.value;
		intYForce=Random.value;
		intZForce=Random.value;
		d20.AddForce(intXForce*100,intYForce*100,intZForce*100);
		d20.useGravity=true;
	}
}

for some reason no matter what i set the variable to ahead of time, as soon as I press jump (space) it just sets them to 0?

Help?

intYForce, intXforce, intZForce are ints. When you assign a floating point value to an int any fractional part is truncated. Since Random.value returns values between 0.0 and 1.0, you will only get 0 for your int values. I’m not sure why you made the three variables ints. The best solution is to make them floats instead. Or you can do:

intXForce = Random.value * 100.0;
intYForce = Random.value * 100.0;
intZForce = Random.value * 100.0;

or you can do:

intXForce = Random.Range(0,101);
intYForce = Random.Range(0,101);
intZForce = Random.Range(0,101);

Then (if you are using ints) your Addforce() becomes;

   d20.AddForce(intXForce,intYForce,intZForce);