- Home /
Question by
Gohst002 · May 09, 2017 at 05:43 AM ·
movementjumpaddforceaddforce movement
AddForce Movement Constraint
I was experimenting with the addforce command and how to make an object move with it. I made a script with it and found that whenever I spam the jump key that the object keeps on moving upwards.
public Rigidbody rB;
public float velocityF = 200f;
void Start()
{
}
// Update is called once per frame
void Update ()
{
if (Input.GetKeyDown ("d"))
{
rB.AddForce (velocityF, 0, 0 * Time.deltaTime);
}
if (Input.GetKeyDown ("a"))
{
rB.AddForce (-velocityF, 0, 0 * Time.deltaTime);
}
if (Input.GetKeyDown ("s"))
{
rB.AddForce (0,-velocityF , 0 * Time.deltaTime);
}
if (Input.GetKeyDown ("w"))
{
rB.AddForce (0,velocityF , 0 * Time.deltaTime);
}
}
How can I make the object jump only two times before landing?
Comment
Your answer
Follow this Question
Related Questions
AddForce to Camera 1 Answer
moving with rigidbody without acceleration 0 Answers
Player appears to teleport instead of adding force 2 Answers
AddForce Jump Doesn't Work 1 Answer
Addforce to create a gliding effect? 2 Answers