I have a top down 2D rpg style game I’m developing and I’ve implemented player movement, which is working fine but I’m not sure how to implement the colliders properly because of the top down style.
So you can image an house which has a box collider 2d on it and the player has a box collider on it, when the player transform position moves and collides with the collider 2d on the house it should stop player movement but instead it does strange things like rotate the map on the Z axis
Anyway I was hoping there was a solution to this that someone knows of perhaps a different way to solve this issue. I would like to define areas that are either out of bounds or that the player is unable to enter for objects like houses, rocks, cliffs, etc
If I put a rigidbody2d on the house and it’s kinematic the player walks through the house without being stopped. if i make turn off kinematic it collides but moves the house like it’s pushing a ball or something around.
I’ve tried messing around with the mass of the house and stuff but I can’t get it to behave how it should. Any other suggestions?
I’ve set the constrains on X,Y but it rotates on the Z axis.
If I set the Z rotation constraints it says in Unity “Rather than turning on all constraints, you may want to consider removing the Rigidbody2d component which makes any colliders static. This gives far better performance overall”
Regardless if I turn on all constraints, the player just walks through the collider.
So if you take the rigid body off you have the sprite & a box collider (not a trigger) & the players collider isn’t a trigger either yet the house moves when you walk into it? Have you tried adding layers & setting them to react to each other?
Have you checked the video tutorials for help? The collides work the same way whether it’s top down or side on. I don’t have access to my 2d stuff but I haven’t had this issue before
My solution was to leave the colliders on static objects with no rigidbody 2d on them, and have the dynamic player object have a rigidbody 2d but freeze the Z axis constraints