Question by
unity_124ggn · Apr 10, 2019 at 09:09 PM ·
collisionmovementgravity
GameObject Doesn't Fall When Moving Or Collide With Objects From Front.
I am new to Unity and am trying to create a crappy game. Whenever my player moves forward or backwards it just keeps moving and doesn't fall. This is odd to me because it falls when it is not moving and moving left to right. He also has RigidBody and a BoxCollider attached. Here is my code: `if (Input.GetKey(KeyCode.LeftArrow)) { rb.velocity = new Vector2(-movespeed, rb.velocity.y); }
if (Input.GetKey(KeyCode.RightArrow))
{
rb.velocity = new Vector2(movespeed, rb.velocity.y);
}
if (Input.GetKey(KeyCode.UpArrow))
{
rb.velocity = new Vector3(0, 0, 1) * movespeed;
}
if (Input.GetKey(KeyCode.DownArrow))
{
rb.velocity = -transform.forward * movespeed;
}
Also in the two images it shows how he moves fine but when you walk off a ledge you just keep moving in the same direction. Thank you in advance!
s.png
(124.6 kB)
capture.png
(224.0 kB)
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612195225im_/https://answers.unity.com/themes/thub/images/avi.jpg)