How to make 2D Collision?

Hello!

How do I make a 2D Box that an object can’t get out of?

For example, similar to the Undertale fight scene where the should is controlled by W A S D and cannot escape the box.

Thanks!

4 Likes

Our lord and saviour EgoMoose has a video on 2d Collision. Searching on the forums and on all Google will yield results too.

6 Likes

Hey there,
There are a few articles on 2D collision you should read up on before posting your question.
Take a read at these threads:

3 Likes

Alright! Is it possible to add W A S D movement to it?

1 Like

This is just basics scripting. If a player press an button, move the box (change X and Y Position. It isnt at this hard). Pls, try before, then ask and show your code. You are askng us to make a code for you, this is against the rules.

1 Like

Uhh, he didn’t create a message which requests anyone to create a script for him.

Also, it’s not as simple as making a system where your like a heart-shaped red hitbox, you’d move around via WASD, and if you program it so the box moves, it wouldn’t be like undertale battle-themed since the box is moving, it’s simple to move the heart.

Also, you would need a barrier for the heart to bump into and not go through the walls.

2 Likes

Yes, I know, but for me he is indirectly asking this. You need first to test it alone, then if it didnt work you ask here and provide the code. He dont tried, so its like he is waiting for us that we make the whole work. If he asked because he just dont have an idea, then its ok. Both of us gave him an direction, now he can script. It is just that I hate if you ask a whole code, you dont learn something new and you still will further ask and ask. But if he try and fail, and show us the code, we can help him better. I hope you understand this.

All I needed was some instructions, thank you both!

1 Like