I’ve looked everywhere on the internet for an answer, but I haven’t been able to find one yet, so I’m trying here.
I’m trying to make a very basic game in Unity2D that involves a player sprite being moved via transform.position. The player has a Box Collider 2D, as well as a Rigidbody 2D. I also have a floor sprite as well that just acts as a static box with a Box Collider 2D at the bottom of the screen. The problem is, when the two collide, the player just goes behind the ground without ever being stopped by it. I set up a collision detector in the script, so I know that the game recognizes a collision is happening, but no actual collision occurs.
Here are the inspectors for both objects:
Player:
Ground:
Nothing is set to Kinematic, everything is set to 2D, both sprites have their Z coordinates set to 0, the player is moving far too slow to ignore a collider as big as the ground’s, and I can’t see anything that would make it so they would pass through each other.
I assume the problem is with the player’s movement being based on transform.position, but I haven’t seen anything online that says that wouldn’t work, so I’m stumped at this point. Hopefully someone here can shed some light on the situation. I’ll give any extra info I might’ve forgotten, and many thanks in advance everyone