Found out the hard way today that if you simply translate an object by calling its position.transform and setting it to some other vector2 (which I’ve been doing to move my character), collisions don’t trigger. To actually make them trigger, you need to do it in the physics. So instead of directly altering the character’s x,y position (this is a pixel-based flat 2d game, by the way, like original Zelda) you need to alter its velocity, which isn’t as pretty.
But even worse than having to get your hands dirty with velocity is how, to make physics collisions work, your rigidbody can’t be kinematic. Meaning gravity will effect it. Of course, there are ways around this, but by this point I feel like I’m going very very out of my way to make something as simple as a collider work (this is an old-school flat 2d game, anyway – I don’t even need true physics at all).
I’m wondering what is the best way to do this?
I have a character sprite walking along the floor. I don’t want him to be able to walk through the wall. What’s the simplest way to do this?
EDIT: I just saw these two hints, but neither of them work for me:
If you are directly manipulating the Transform component of your object but still want physics, attach a Rigidbody and make it Kinematic.
If you are moving a GameObject through its Transform component but you want to receive Collision/Trigger messages, you must attach a Rigidbody to the object that is moving.
If I make my character kinematic and then alter its Transform.position to relocate it pixel by pixel, eventually hitting a collider, nothing happens: the object goes right through it, and the collider method isn’t even called.