Javascript Movement too slow or fast.
I am making a small maze game on my own. The only issues I am running into is the speed of the movement. I only have the move right because adding more is useless unless I fix the speed of moving right. Changing the value of the speed doesn't do anything. Here is my code:
var speed : float = 0.02; //Speed of the movement of the player.
static var isDead : boolean = false; //Will be used later.
function Update(){
if(Input.GetKey("right")){ //Move right.
transform.Translate(Vector3(speed, 0, 0)); //Executing the movement.
}
}
I am not a genius but I am only in IMP (Interactive Media Production) in High School. However I can code pretty well. Its just this piece is confusing. I have tried "speed, 0, 0" and "speed * Time.deltaTime, 0, 0" but the one with the Time.deltaTime moves way to slow regardless of the speed value.
Answer by Jason2014 · Jun 18, 2017 at 03:00 PM
You have to multiply speed value by Time.deltaTime to move an object independently of frame rate and significantly increase speed value to see the effect (4 for example). Decimal value which you using is definitely too small.