[solved] Problem with collision in mobile character

Hi everyone! I have a little problem with my hero and collision detection. I loaded my hero (by asset Manager). After that i added capsule collison shape, created character control from this capsule and finally add control to physics and to node. Here is code:

[java] CapsuleCollisionShape capsule = new CapsuleCollisionShape(0.5f,0f);

controls = new CharacterControl(capsule, 0.05f);




mobile = new Node(“mobile”);






After that I have something like this:


As you can see, capsule is under my hero. I also try to make bigger capsule but always capsule is under hero (and because of that he is in the air). So I created the capsule like this:

[java]CapsuleCollisionShape capsule = new CapsuleCollisionShape(0f,0f);[/java]

Now it’s ok but hero’s legs are too close to obstacles (for example blue box). So I would like to make a capsule and put my hero inside it, to make him “surrounding” by capsule. It will also be better, cause when I jump the obstacle will stop me (cause hero’s head will be in capsule).

How to do this?

This has been solved multiple times on the forum. The center of your model is at its feet, the center of the capsule is at… its center. Use a node to translate your model. Also please read the javadoc, a capsule with height = 0 is probably not what you want.

Ok, of course that capsule with height = 0 is not that what I want. But what you mean in “Use a node to translate your model”. I don’t want to change position of my character (unless I have to). When I use: node.setLocalTranslation(…) it doesn’t work cause my character is getting up and fall down because of gravity.

Ok, I red in different topic that I must for example add an offset variable to controls. But I have no idea how to do this.

Add the spatial to a node, move it down. Add the CharacterControl to the node.


1 Like

Ok, it works, thank you very much :slight_smile: