- Home /
My Rigidbody character bounces in the air when trying to move towards an enemy it is colliding with.,For some wierd reason my character with rigidbody just bounces over another rigidbody enemy when i give directional input.
So here's some wierd behaviour I encountered.I have a simple character that uses my custom script for movement .My character has a rigidbody and a box collider and uses RigidBody.movePosition to move.The issue is when my character moves toward an enemy character which also has a rigidbody and a box collider my character kind of climbs on top of the enemy and sometimes even launches the character in the air.I even tried using rigidbody.position instead of moveposition to see if the function was generating the upwards force to no help. i have attached a video showing the issue with the physics profiler turned on.Any one have any idead how to fix the problem.I even removed all scripts from one of the enemy objects and it still launches me in the air if i try to move toward it when we are already colliding.Also something thast wierd is if the character lands on top of the enemy the character bounces away. Here's a link to a video showing the problem. https://youtu.be/xA4EEgOetfU
Answer by RohanP · Feb 01, 2021 at 06:41 PM
It turns out that its probably being caused by the navmesh agent Component in the enemy character.Removing the agent component seems to solve the issue.At least this issue.If anyone has any ideas please help.
Its wierd how only i am replying to my own question.It turns out that this is happening when rigid body on the enemy is not kinematic and the navmesh agent is active as well.either disabling the navmesh agent or setting the rigid body to kinematic solves the issue . If anyone else faces the issue now you know.A stupid mistake i guess considering the unity official documentation explicitly states to keep navmesh agent rigid bodies to kinematic.SOme script is setting the rigidbody to normal non kinematic mode.I guess i have to fix that.
Your answer
Follow this Question
Related Questions
Rigidbody MovePosition based on the direction facing, but with x and z values calculated separately? 1 Answer
Trouble with implementing Vector2.ClampMagnitude in the Rigidbody2D.MovePosition function 1 Answer
Move rigidbody with mouse with realistic physics interactions with other rigidbodies. 0 Answers