Hi,
I am trying to make a simple Endless runner.
So I attached a rigid body to a square and this javascript:
var Speed : float = 10;
var High : float = 300;
functionFixedUpdate () {
rigidbody.AddForce (Vector3.right * Speed);
if(Input.GetKeyDown ("w"))
{
rigidbody.AddForce (Vector3.up * High);
}
}
But for some resin if i press “w” for the first tint at the beginning the ridgidbody jumps really high.
Also if i jump the rigid body is moving faster to the right if i press “w”.
Can anyone help my?
P.S. The rigidbody is on Interpolate.
Thanks for any help.
you variables are called “varSpeed” and “varHigh”, in the code you are using “Speed” and “High”… ?
also code tags please when you paste in code Using code tags properly - Unity Engine - Unity Discussions
1 Like
It’s a formatting error, there’s no space between var and the variable name, if their name was varSpeed and varHigh it wouldn’t even compile.
@UnityBasic try rigidbody.AddForce (Vector3.right * Speed * Time.deltaTime); or rigidbody.AddForce (Vector3.right * Speed * Time.fixedDeltaTime);
If you don’t do this the speed will be machine dependant, that means the faster the computer is the higher the speed.
1 Like
ah so it is… guess it’s “code tags”, “code tags” from me then lol