CharacterControl entities can walk through each other

Hi I am trying to get these entities to hit each other like normal objects

I modified the tutorial

I added in a 2nd character to test

CharacterControl ndChar = new CharacterControl(new CapsuleCollisionShape(0.5f, 1.8f), .1f); ndChar.setPhysicsLocation(new Vector3f(8, 1, 8)); characterNode = new Node("character node2"); model = assetManager.loadModel("Models/Sinbad/Sinbad.mesh.xml"); model.scale(0.25f); characterNode.addControl(ndChar); getPhysicsSpace().add(ndChar); ndChar.setApplyPhysicsLocal(true); rootNode.attachChild(characterNode); characterNode.attachChild(model);

This code is inserted after the camera is initilised and the original character is added in the simpleInitApp function

Does anyone know why these 2 characters dont run in to each other please?

Thanks for any help

Cause they don’t ^^ You’d have to check for that otherwise. Search the forum, theres been several solutions for this.

Sorry not quite following? what does the monkey symbol mean and why would i have to manually check for collisions?

I will take another look through the forums for previous solutions

The monkey symbol is a smiley…

And you have to manually check for collisions, because the CharacterControl emulates physics in a simple way and the developer didnt find it handy to add the functionality internally. But seriously: Its not that hard and once done you are ready, where’s the problem? :wink:

But seriously: Its not that hard and once done you are ready, where’s the problem?

I have searched the forum, but I'm stuck with this too. I think it would be very handy to have one example of this in the tests.

Ok thanks for explaining KuroSei :slight_smile:

I have to agree with Vortex this seems like something that absolutely everyone is going to have to implement for any game using this engine? it would be nice to have a good concrete example that shows at least two character type physics objects actually colliding and rebounding of one another

The reason I am suggesting this is because there seems to be a few examples sprinked throughout the jme3test examples that use ghost objects and others that use overriding the simpleUpdate from Application to find and sort through collision results but all the examples Ive mentioned that Ive found dont prevent meshes from intersecting only report when they do

Once we detect a collision what are we meant to do to prevent the meshes from intersecting further?

Thanks for the replies everyone

i am wondering that too

but if we use collision listeners, we probably know what body intersect with wich other body

then (as they are capsules) you got a ray build from the centers of those 2 bodies

then you can apply forces based on that ray to make them expulse

but i agree, the implementation depends on the game you want to create

a nice example would maybe help people (and me too) i guess

i haven’t used any physics at all, and skipped all physics tutorials. But based on common sense the engine should provide the .normal of the vertex they collided, use that to apply a force on the characters.

I agree, i am trying to check that out

so far :

bulletAppState.getPhysicsSpace().addCollisionListener(new PhysicsCollisionListener() { public void collision(PhysicsCollisionEvent pce) { System.out.println(pce.getNodeA().getName()+" collides "+pce.getNodeB().getName()); } } );

i see that the main character(player) is colliding with the scene only if a force is aplied to it) and that's all
so my other caractercontrols(enemies) don't collide with anything

and if i check the doc, i don't see how to get that normal to base my expulse forces on

getAppliedImpulse() A float value representing the collision impulse
getAppliedImpulseLateral1() A float value representing the lateral collision impulse
getAppliedImpulseLateral2() A float value representing the lateral collision impulse
getCombinedFriction() A float value representing the collision friction
getCombinedRestitution() A float value representing the collision restitution (bounciness)

nothing seems to return any collision point/face_normal

jesus why is there no simple example for such a simple case
i find it hard to believe someone has made an fps with jme3 without rewriting a whole physcal control
any hint ? I am lost and confused

I hope the jME3 beginners book is going to give some light in the dark…

I have reverted to using a simple RigidBodyControl with a BoxCollisionShape for now that detects collisions by itself and seems to work ok for the most part

Thanks everyone and im glad other people are having the same issues maybe someone will build a tutorial soon to address this

or finish coding the character controller class heh either way

I tried modifying BombControl class briefly to detect char on char collisions but it wasent working quite like id hoped and in the end the simple solution worked well enough

so far i got it working

it is really basic but it works

//---------------------------------------------------------------------- CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(1.0f, 2.0f, 1); playerBody = new CharacterControl(capsuleShape, 0.05f); playerBody.setJumpSpeed(20); playerBody.setFallSpeed(30); playerBody.setGravity(30); bulletAppState.getPhysicsSpace().add(playerBody);
    playerSpatial = (Node) assetManager.loadModel("thing

playerSpatial.setLocalTranslation(20, 20, 20);

    RigidBodyControl rbc = new RigidBodyControl(capsuleShape);

the problem is the repulsing forces,

they got to be calculated regarding the distance between objects, point of intersection, normals ....
it should be made out of constraints like with NewtonPhysicEngine but i don't know how to do this with JME/bullet and i am not mathematician, integration is not an easy concept

so here is a global reaction force calculation,
it is crappy but you get the idead
the advantage is that it is quiet fast.
here, other entities are moving away from the main player
bulletAppState.getPhysicsSpace().addCollisionListener(new PhysicsCollisionListener() { public void collision(PhysicsCollisionEvent pce) { if(pce.getNodeA().getName().equals("ground")) return; if(pce.getNodeB().getName().equals("ground")) return;
            Vector3f p1 = pce.getNodeA().getLocalTranslation();
            Vector3f p2 = pce.getNodeB().getLocalTranslation();
            Vector3f delta = p2.subtract(p1);
            CharacterControl cc1 = pce.getNodeA().getControl(CharacterControl.class);
            CharacterControl cc2 = pce.getNodeB().getControl(CharacterControl.class);
            cc2.setWalkDirection(delta.mult( 0.22f));
    } );

any advice would be really welcomed, especialy from the brains of Jme project who understand this better than any regular (non mathematician) programmer

althought i must say jme is by far the most advanced, top level 3D game framework i have been using

please give advice for the non math people

now i reallize i wrote the solution

what if i used hard joints at each impact point ? dyamicaly add them ad remove them,

that is what we do with newton engine if i remember well

  • but how do i get the point of intersection / normal to collision ?
  • is there a hard constraint joint? i guess a 3DOF joint would do the trick
@normen said:
Cause they don't ^^ You'd have to check for that otherwise. Search the forum, theres been several solutions for this.

can you tell me how to get the Vector3f intersection point at collision time ?
by using simple 3dof hard joints at each impact point, meshes will never overlap

ok i guess using collision listener or physicstick listener and probably using a ray to check for the collision point

anyway this is complicated, and there is nothing in the wiki nor in the forum that i could find

plz give me some light ? :frowning:


@rompelstilchen said:
hmm got a mail saying you replied to me, where is the answer , lol


thx mate :wink:

lol yes, page 2 i know, no comment

ha ha ha

can’t always be at my maximum ha ha

for those interested

i found this :

hope this helps (me and others)[]=ghostcontrol