- Home /
2D game Player walks trough walls
hello there.
im a beginner in Unity and i am making a 2D game. the problem is: i got a wall in my world. like a fence or a brick wall. you know what i mean. but my player keeps walking trough the walls. i already set up colliders for the sprites (walls) same for the player. but when the colliders touch each other. they ignore each other and the player can walk trough it. i think i need a script for it. but i dont kniw wich script.i already searched on google but it didn't help me. hope someone out there know it!
thanks! Bram Z
Did you make sure that box collider is checked off? If it is make sure "Is Trigger" is not checked off.
also make sure you character is alligned on the z-axis with the walls or they won't collide
Well you can check if collider are placed in right position. You can check this by selecting your player and wall and watching game played in editor.
Answer by joseques · Mar 22, 2014 at 01:29 PM
Bu sure youre using Colliders from the Physics 2D of the components menu. The z axis it's not important in 2D collisions. Check you are using colliders2D and rigidbody2d with your gameobjects.
z axis can be if you're doing 2.5, like layering sprites or what not.
Yeah the layers visually will be separated but the collisions still works. I have an image explaining that but im not on my computer right now.
If you want a more deeper explanation. Look my answer at this thread
Answer by Bramadian · Mar 26, 2014 at 08:42 AM
thanks, i fixed it and now it doesn't walk trough walls anymore. now im a little bit closer to finishing the game. thanks!
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
A node in a childnode? 1 Answer
Delete object when two collision or more 1 Answer
Vector3 being treated as a variable 1 Answer
Terrain isn`t working PLEASE help 2 Answers