Bug - Able to pass through rigidbody/collider when using Lerp/SetPosition
I've got a click-to-move player (the black box) and an enemy (the red box) and for some reason, my player is able to pass through the enemy if I drag far enough.
I've tried every combination of sensible changes I can think to make, but still can't figure out why the player is able to push inside of the enemy square and doesn't stop when their colliders touch. Much less the whole ability to teleport to the other side thing.
This also manifested in a game-breaking way when I try to implement walls that the player can just teleport to the other side of if you drag far enough.
What am I missing? I've tried Discrete and Continuous collision for both the player and enemy, I have the player set to a Dynamic body type and the enemy to Kinematic so that it would only collide with the player, but I've tried every combination of that as well. The 2D Box Colliders are set to the edges of each square.
I'm wondering if it's how I'm calculating player movement. Currently, I'm using a Lerp between self position and the mouse position and using Transform.SetPosition to move the Player. If there is a better way that achieves the same type of movement please let me know. Thanks in advance.
Transform != Physics/Collider.
If you use transform.setPosition, Unity will let the object glitch through every object (beside static 3D collider).
If you want to lerp transform then use rigidbody to move your box ins$$anonymous$$d.