Simple Wall Collision

Hi, complete noob here! I searched around and I cant seem to find a simple tutorial on basic collision.

I am working with the Astronaut tutorial, and I decided I wanted to just make walls so that he couldn’t walk off the screen.

I created a Kinematic box for him, and drew four static objects on the walls. Like a noob I guess I just expected that to work.

I

I played around with it and got some funny reactions (like making the map Dynamic so he pushed the level around.

But I guess I’m going to need to script what happens when the things collide. I am completely new to LUA , so
I was imagining where I would put it in the code and had a question?

  1. if the astronaut is walking left (-x) and he bumps into the wall, do I need to set his -x velocity to 0? How can i get the expected behavior of the “left” animation still playing without him moving?

  2. can anyone point me to a simple script that handles a collision between a static and kinematic body?

  3. If i keep at this, then someday I will be able to do this myself, right? I feel like a baby lol

Thanks to any kind souls who read this :smiley:

Here you go.

And I think making walls kinematic too is better.

2 Likes