Question by
BetrayedPickle · Mar 31, 2019 at 09:19 AM ·
physicsskateboardskating
When key pressed addforce,How do I add force when key pressed. Skating physics
Hi I am making a skating game and I want to do a command like this.
When W key pressed addforce. I want to try to make skating physics with the addforce. I have tried myself and this is what I got.
public Rigidbody rb;
public float thrust;
void Start()
{
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void FixedUpdate()
{
if (Input.GetKeyDown("w"));
{
rb.AddForce(-transform.forward * 500);
rb.useGravity = true;
}
}
},Hi. I am making a skating game and need help on a command like this. When W key pressed add force.
I have already tried myself and this is what I got.
public Rigidbody rb;
public float thrust;
void Start()
{
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void FixedUpdate()
{
if (Input.GetKeyDown("w"));
{
rb.AddForce(-transform.forward * 500);
rb.useGravity = true;
}
}
}
Comment