I am working on a 2d game and solve every aspects on Z axis.

My problem is How do I put a imaginary wall on the side of the screen so that the mouse and spatial will not move out of the rendered window.

The spatial (a sphere) is mapped on the 4 mouse axis triggers (negative and positive) and moves accordingly.


Create a cube with collision.

Then attach it to the camera.

Then make the size and offset so that the edges of the cube is at the edges of the camera.

Then put it in collision_group_5 or something. And enable only the player to collide with that group.

so the game space would be inside the cube? Im working on 2 axes only.

edit: my collision is handled by the physics of BulletAppState.

On your physic character do:


and on the cube do:


This way. the character collides with the cube but nothing else.

Doesn’t mather if you work on 2d, as this the other sides wont be a problem.

It’s a simple solution instead of custom making some walls in blender and export and stuff. This would be easiest and with no disadvantage…

Thanks for the “quickest” reply.

I know about the collision group, what I don’t know is the cube attached to the camera.

I’m using the default camera of SimpleApplication - cam - and haven’t done anything to it except .setLocation(…).