Hi everyone,
I’m not sure what’s going on, but last night I closed out my Unity session with everything working as intended, and this morning I noticed that for some reason the game view is not showing hitboxes working correctly, but the scene view shows them working normally. I am using a raycast controller for a 2D game, and have had 0 issues with anything for the past several weeks of working on this game.
To be clear, my player’s box collider is able to move into the box collider of a wall, or the ground, by half the size of the box collider of that object. I am not able to pass through these objects, and everything else works fine.
In the scene/editor view the collisions appear to be pixel perfect, so I have no idea what’s going on.
I just want to add that I found something very odd that is happening…
Again, in the scene view everything works as intended, but oddly enough when I move my platforms higher up the player’s hitbox is displaced based on the value of the x or y direction in the game view. Like, if I have a platform to land on top of that is placed in the world with a y position of -.65, my player falls into the hitbox of that object by .65, but would be pushed UP by .65 if the value was +.65.
I want to make it clear that after everything was working fine last night I changed NOTHING to any script or any setting in the inspector on any object.
Can you post a screenshot? And post a screenshot of the player setup in the inspector?
One more update: I made a new project, imported all of my scripts, set up the values as necessary and everything in that project works as intended in both scene and game views.
As I mentioned, creating a new project seems to fix everything, but I’d rather not have to redo all of the setup in a new project to make this issue go away since I have so much already done in my current project.
Update:
Changing the camera from perspective to orthographic fixes the issue, BUT in a new project I can use perspective just fine.
Strange. I don;t know anything about 2D or orthographic cameras.
They only thing I can think of is that the game camera is looking in a direction that makes it appear that the player has passed through the ground, but it actuality the player is standing just fine on the ground fine.
Maybe someone with more experience with 2D can reply to this thread.