- Home /
Shaking While colliding
Hello Unity! I am making a 2D game, and I have tried putting box colliders on my furniture. It works great, except when my player continues to run into the furniture, my player shakes. How can I prevent this, and make my character just stop moving when it runs into the furniture?
Comment
Answer by moltow · Jul 28, 2017 at 11:04 PM
You could do something like... (note: rb2d would be your character's RigidBody2D that you got a reference to outside of this method)
void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.tag == "Furniture")
{
rb2d.velocity = Vector2.zero;
}
}
Your answer
Follow this Question
Related Questions
2D Animation does not start 1 Answer
Teleport 2D Player to another room 2 Answers
Megaman Movement 0 Answers
Is there any benefit to slicing in power of two dimensions inside a sprite sheet? 1 Answer