random interval

Hi everyone , Does anyone know why does this code execute only one time:

the guy should jump every time jumping is false and mynum < than 3

thank you

var EvilGuy : Transform;
var jumpsound : AudioClip;
var Jumpping : boolean =false;

var rangeDice : int ;
var mynum:int;
function FixedUpdate(){

rangeDice=Random.value* 20+1;
mynum =rangeDice % 3;
Debug.Log(mynum);
Debug.Log(Jumpping);

if(mynum==1 && !Jumpping)
{
MakeHimJump();
}
}

function MakeHimJump  () {
     //var randomValue : int = Random.Range(1, rangeDice);
     PlayAudioClip(jumpsound, transform.position, 1);
     transform.position.y+=2;
     if(transform.position.y<=3){
     Jumpping=false;
     }
     else{
     Jumpping=true;
     }

}

MakeHimJump is the only code capable of making Jumping false. However, MakeHimJump only executes when MakeHimJump is false. Once your code sets jumping to true, it is unable to set it back to false because that part of the code was disabled.

EDIT: Removed Mathf.Round calls as they are not needed.

In response to your issues with random, it is because you are getting a new random number every few milliseconds. You should instead try getting it every second or so. For example:

JS:

public var lt : float = -2;
function Update()
{
if (lt == null || lt == 0)
{
lt = -2;
}

if (Time.time - lt >= 0.9)
{
lt = Time.time;
generateRandomNumber();
}
}

function generateRandomNumber()
{
//Do any kind of number generation here
}

c#:

public float lt;
public void Update()
{
if (lt == null || lt == 0)
{
lt = -2;
}
if (Time.time - lt >= 0.9f)
{
lt = Time.time;
generateRandomNumber();
}
}

public void generateRandomNumber()
{
//Do any kind of number generation here
}