Physics objects pass clean through each other

I must be doing something dumb here. Anyways I have 2 physics objects (both RigidBodyControl’s)


  1. The player ship uses a SphereCollisionShape
  2. The meteor/rock uses a CollisionShapeFactory.createMeshShape



    When I apply a force to the players ship towards the meteor when the “hit” they pass through each other. Maybe my understanding of how these physics objects work. I would’ve thought that they’d sorta just hit each other and that’s it.



    Through the examples I’ve seen it should just “work” but I’m obviously missing something.
@thecyberbob said:
I must be doing something dumb here. Anyways I have 2 physics objects (both RigidBodyControl's)

1. The player ship uses a SphereCollisionShape
2. The meteor/rock uses a CollisionShapeFactory.createMeshShape

When I apply a force to the players ship towards the meteor when the "hit" they pass through each other. Maybe my understanding of how these physics objects work. I would've thought that they'd sorta just hit each other and that's it.

Through the examples I've seen it should just "work" but I'm obviously missing something.


Did you set the mass for both objects?

I would recommend posting some code where you show how you initialize the rigid bodies.

Your not moving the rock are you? If not, did u add any collision masks? Is the ship moving really fast? do you have debug shapes turned on? You don’t really provide much info.

@yuxemporos said:
Did you set the mass for both objects?


Nope I did not. I'll do that tonight and give it a whirl.

@wezrule said:
Your not moving the rock are you? If not, did u add any collision masks? Is the ship moving really fast? do you have debug shapes turned on? You don't really provide much info.


Nope not yet anyways.
I thought I did but there's a good chance I did not.
Not overly so.
Yup. Both shapes are highlighted correctly.
Sorry about that. I was kinda hoping for hints just to see if I could solve it myself with limited aid. I'll try the mass thing yuxemporos mentioned if that doesn't work I'll post an update here with some code snippets.

Thanks!

enable the debug shapes, that will probably help quite much

@EmpirePhoenix said:
enable the debug shapes, that will probably help quite much


That's the odd thing. I have. When my little ship's collision sphere hits the mesh shape for the meteor/rock it just continues going right on through. If the game I was making was based on say "The Adventures of Buckaroo Banzai Across the 8th Dimension" this'd be sorta ideal (I may be dating myself with that film a bit. Oh well). But it's not. I was kinda hoping for more solid asteroids.

Then show code of both stuff, especially wher you set mass shape ect.

Will do tonight. Thanks guys!

@thecyberbob said:
Will do tonight. Thanks guys!


One more major thing, the physics have to be activated in the main program! I don't think you mentioned doing that step.

In the main class:
BulletAppState bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);

then you need to add your RigidBodyControl to the bulletAppState

this.rigidBodyControl= new RigidBodyControl (new SphereCollisionShape(radius),mass);
this.addControl(physics);

Main.bulletAppState.getPhysicsSpace().add(this.rigidBodyControl);

Bwa-HA! Got it. It was the mass issue. I also had to set this:



[java] bulletAppState.getPhysicsSpace().setGravity(Vector3f.ZERO);[/java]



Just so that my meteor didn’t fall away into space.



Thanks!

your meteor should have a mass of 0, or set it to kinematic

Huh. Ok. Just set the meteor to 0. Seemed to work too. Thanks :slight_smile: