Collision Issue

Hi everyone!

I have small issue on hand; I’ve been looking through various topics and I didn’t find anything related to my issue. Maybe it’s because I’m getting a little bit frustrated here :slight_smile:

I’m developing a 3D Isometric maze game where you control a box. My issue is that I want it to stop moving (even when a user presses a movement button) as soon as it hits a block wall. I’m using a ‘RigidBodyControl’ for both the character and the wall.

I did use the ‘CharacterControl’ for the character but personally I think it’s not a suitable method for adding collision to my specific box character.

So basically, I want both the character and the wall to be solid so that nothing moves past/through them.

Thanks guys!

If you are using physics then rigid body objects already are solid (unless they are kinematic). Make sure you only move objects by applying forces to them, NOT by setting the location. It is explained here:

1 Like

Thanks! Is it possible to apply force using a key listener like an Analog Listener or can I only apply force using a Physics Tick method?

In general it is Not A Good Idea to do physics on another thread so only use physics tick method. I do it like this, key/analog-listener sets a few AtomicBooleans to indicate what keys are down/up. Then I have a control attached to the Spatial I want to control, the control is a a physics tick listener, when it is called by the engine it looks at those AtomicBooleans to determine what forces to apply. Works pretty good.

1 Like

OK thanks man! You’ve been great help.

Hello Sir, I am newbie and I am facing issue of your “Hello Physics” example. I have created 2 file. one file contains all code related to sphere and other file contains all code related to floor and wall. Problem in that when i executes the main file(in which i defines floor and wall) my sphere doesn’t collide to the wall and floor. It penetrates the wall and floor. The code works fine and my sphere collides well with the wall and floor when all code only in one file… Please help me why it is happening and how can i fix it. I stuck here from 2 days.

Hello Sir…I got the issue… I was defining BulletAppState for both file. Now I place BulletAppState only in main file and its working. Thanks

Is BulletAppState should be define only once(in my case i defined in main file)?. Why is it not performing collision detection if I defines BuletAppState for each file?

Hi pankaj

By defining BulletAppState for both files, do you mean you create two different instances of BulletAppState’s? If that’s the case, then it won’t work. I might be wrong but its like creating two different physic’s worlds that’s not related. If you want to add collision shapes for objects, then just add them in one BulletAppState.

Thank you very much James.