- Home /
Rigid Body and Collision practice
Hello , I would like to hack and slash through my 2D enemies sprites and I am confused how should I manage their rigid bodies and colliders so that the collision is accurate because the animation of my player is going to be fast.
So how would an expert do that ?
Thank you :)
Answer by DanielRS · Feb 28, 2014 at 08:13 PM
Hello, that happens because the colliders are going too fast, here's an example:
Player is at position <0,0> and moves horizontally by <4,0> each frame. Now, you have an enemy at <6,0>, here's the flow of the game:
Player at <0,0> game starts
Player at <4,0> no collisions detected
Player at <8,0> no collisions detected
As you can see, the player ignored the enemy position, because between each frame, the player moved past the enemy, not triggering the collision.
The way to fix this is to set the "Collision Detection" property in the Rigidbody component to "Continuous" or "Continuous Dynamic" depending on your needs.
Thank you , I understood that . But I would like to know if attaching a trigger collider2D and a kinematic rigidbody2D body to all the weapons in the game is a good practice ?
PS : $$anonymous$$y enemies and the main player have already a non kinematic rigidbody2D, so that they are influenced by unity phys engine.
@oleg9419 I don't think is a bad practice, but you will have to move the $$anonymous$$inematic rigidbodies using Transform. Check this page for more information.
Your answer
Follow this Question
Related Questions
Collider going through walls with box collider.. 1 Answer
Box Edge Collision Problems 0 Answers
Can Kinematic Object collide with other Kinematic Object? 1 Answer
What is the cheapest way to prevent object A from going through object B 3 Answers
Preventing objects from intersecting with minimal physics 3 Answers