Prevent objects from coliding

Hi,

I am trying to evolve(using genetic algorithms) a behavior for my NPCs. In order to that i need several NPCs to act in the same space

without interacting with each other. Can anyone tell me how can i add two different objects to the physics engine in such a way that they

interact with the world but not with each other?



Thanks,

Dmig.

look at control.setCollisionGroup() and control.collideWithGroup() there’s an example.in the jME tests

Goes this way (if I understood right):

For each collision controller, you can define:

  • what collision group they belong to (singular) (:edit: can be plural too… :edit:, thx to a post by normen)
  • what collision group they collide with (can be null, singular or plural)



    By default, all controllers “belong” to collision group 1 and collide with collision group 1.



    Use the constants (PhysicsCollisionObject.COLLISION_GROUP_01 etc) instead of directly inserting the int values.



    NB: collision between 2 mesh shaped controllers will throw an exception… at least one of the colliding controllers need to have a non mesh collision shape.



    NB2: probably a good idea to remove collide with when there is no point for that to be checked… for example, when I enter my spaceShip (well, an empty box model) and get in pilote mode (and attach my character to the ship)… there is no point in checking for collisions between that character and the ship.



    NB3: basically… what wezrule said… in more words :D. I’ve learned plenty by reading answers from monkeys… I thought it may help someone if I added some stuff I found useful to keep in mind. Sorry if it looks like unorganized mindless blabber :D.
2 Likes

Almost right @loopies, but they can also belong to multiple groups, extending the options immensely :slight_smile: The javadoc of the corresponding methods should give more info.

Doh… wooot… stuck between the shame of bringing incorrect data and the joy of that added potential.

Thx for the info normen… really great news for me.

Thanks for the quick answers.

So what is the relation between RigidBodyControl and the “collision controller” you are talking about? my intuition says:

RigidBodyControl is a “collision controller”, but RigidBodyControl is a PhysicsRigidBody which in turn is a PhysicsCollisionObject and that is the top of the inheritance tree…



so i guess my question is what do you consider a “collision controller”?



Edit:

i have been reading the documentation that you guys suggested and i have another question,

Are there two bitmaps for every controller, collisionGroup and collideWithGroups, or is the same bitMap used for both? meaning:

if i execute setCollisionGroup(COLLISION_GROUP_2) on all my NPCs and also setCollideWithGroups(COLLISION_GROUP_1) and don’t touch the collision groups of anything else. will my NPC’s interact with everything in the game world except each other? or will they still collide with each other?



Thanks again,

Dmig.

Obviously theres two, else what would be the point?