- Home /
,Player Passes through walls 2d
I'm knew to unity and I don't really understand how collisions and rigid bodies work and I don't know what types of what to use or when to use colliders for physics. All I want to do is to have a player which I currently control with a rigidbody2d and wall which I am unsure what to do with. Everything I have tried so far results in the player phasing right through the wall. Could someone give a brief explanation of how collisions work and what bodies wont phase through each other?
Your player needs a 2D Collider attached so it will collide with the wall. The wall also needs a 2D Collider. All 2D colliders wont phase though each other by default, same with 3D colliders unless you specify then to ignore each other using the physics matrix inside Project Settings.
Answer by Coolboi_21 · May 17 at 02:50 AM
By giving your player a rigidbody they will now have physics. What this means is they will have gravity (if you select that option) and have collision with objects (keep in mind you also have to give your player a collider for it to have collision). You have to make sure that the objects you want your rigidbody to collide with, have a collider component. There are many different shapes of colliders. There's colliders in the shape of a square, circle, and many other shapes. If your wall is a rectangle or square you would give it the Box Collider 2d component . If it was a circle then you could use a Circle Collider 2d. In short, all the different colliders are there to fit different shapes and use scenarios whether that be 2d or 3d.
Hope this helped @benlyons05!
Your answer
Follow this Question
Related Questions
Why does poligon collider 2d restricts movement of box collider? 0 Answers
Colliders2d not colliding, yet stoping the rigibody2d. 1 Answer
reversing current velocity of 2D rigidbody with button press 0 Answers
Way to achieve 3 lane mechanism in a 2D game 0 Answers
How to create a Drag & Drop system which verifies what gameObject was dragged into the slot? 0 Answers