- Home /
Player getting stuck in ground (3D) player has Rigidbody, and Box Collider, world is Mesh Colliders
Hi everyone. So my player has a game object for physics which has Rigidbody and Boxcollider. And the world which is made of Unity cubes have mesh colliders. But I notice while the player moves there are instances in which he gets stuck in the ground (I think he is) and his z position gets stuck at (X being a number in front): X.49998 (like it is trying to round off but can't. By turning off use gravity and the collider of the player it doesn't get stuck but just slides across the world which is not ideal for the type of game.
I have attached the code for moving below:
void Update()
{
if (PlayerCollision.HasFallen == false)
{
if (Input.GetKeyDown(KeyCode.RightArrow))
{
Rbody.velocity = new Vector3(1f, 0f, 0f) * Speed;
Jump = true;
}
if (Input.GetKeyDown(KeyCode.LeftArrow))
{
Rbody.velocity = new Vector3(-1f, 0f, 0f) * Speed;
Jump = true; //For animation
}
if (Input.GetKeyDown(KeyCode.UpArrow))
{
Rbody.velocity = new Vector3(0f, 0f, 1f) * Speed;
Jump = true;
}
if (Input.GetKeyDown(KeyCode.DownArrow))
{
Rbody.velocity = new Vector3(0f, 0f, -1f) * Speed;
Jump = true;
}
}
Any ideas why my player is getting stuck? Thank you.
Your answer
Follow this Question
Related Questions
How can the player position updates randomly when the player isn't movingl? 0 Answers
Collisions causing Rigidbody to go Haywire and move randomly. 1 Answer
Issues Making Character Move With Rigidbody 1 Answer
Always Get Same Physics Collision Rebound Force 1 Answer
Simple Movement Game: Physics vs Manual Collision Detection? 2 Answers