Hi! i am working on a maze game, and I don’t know how to make it when my player collides with the wall, he can’t go through it, like a wall. if you couldn’t tell, I’m relatively new at this so thanks for the help.
Make sure the walls & player have colliders & at least one of them have a rigidbody2d.
Have you done the tutorials for 2d?
My wall has a collider and my Player has a rigidbody, ill make sure they are 2d though. And no, i jave not bren following a 2D tutorial.
Add a 2d collider to the player
So my player should have a 2d collider and my wall should have a 2d RigidBody?
It depends on a lot of things about how you are doing the game. I suggest you do the tutorials where they cover these things so you can work out what is best for your game.
Your wall and player need to have a Collider2D (BoxCollider2D most likely), and one of the items needs a rigidbody2D (most likely your player).
Yea both need some type of colliders, your character can have a rigidbody aswell.
Not adding a Rigidbody2D means the colliders are static and should not be moved. The physics system won’t move them either.
Your player should have a Rigidbody2D as well as its collider(s). If you are moving it adding forces to the Rigidbody2D then leave it as dynamic (don’t check the Is Kinematic check-box). If you are moving it via modifying the Transform component directly then check the Rigidbody2D IsKinematic check-box.
Or you could do some good old raycasting.
I have a collider on both and my player a rigidbody, it still wont work. When i check and uncheck Is kinematic, it makes no difference.
I would suggest going through the 2D physics overview here assuming you haven’t already.