- Home /
Question by
JeffreyRocks · Sep 29, 2021 at 12:51 PM ·
addforcerigidbody.addforcetransform.forwardrigibody
AddForce(transform.up) works but AddForce(transform.forward) does not
// this works
if (Input.GetKeyDown(KeyCode.UpArrow))
{
Rigidbody2D tester = this.GetComponent<Rigidbody2D>();
tester.AddForce(transform.up * 1000f);
}
// i change it to this it does not work
if (Input.GetKeyDown(KeyCode.UpArrow))
{
Rigidbody2D tester = this.GetComponent<Rigidbody2D>();
tester.AddForce(transform.forward* 1000f);
}
Heres a screenshot: https://snipboard.io/T0MXFK.jpg
Comment
Answer by Bunny83 · Sep 29, 2021 at 02:42 PM
Well, you work in a 2d setup here. So using transform.forward makes not much sense here. You only have the x and y axis in 2d which is transform.right and transform.up.