I use a CharacterControl for my character and a RigidBodyControl for my floor.
The problem I have is: When I move the character up and down only(only in z direction) and in no other direction, it “slides” to the left.
Meaning it slowly but surely also changes its x-location.
Is this a bug or intended behaviour?
If not a bug, how can I avoid this?
When you move it down into the terrain you create an impossible physics situation, it will result in the character trying to somehow avoid that. Where it moves to is probably dependent on the mesh/vertices around that location. If you just move it up that does not happen, right? Also, you hopefully only move it using walkDirection?
With “up/down” I meant the z-direction. Forward and back. And yes, I only move it with setWalkDirection.
Uh, are you sure this is not due to your code? what happens if you set the walkdirection directly with a vector like (0,0,1) in simpleUpdate()?
It still slides.
Can it be because of the CollisionShape of my floor? My floor/scene is a simple plane and I create its CollisionShape with the CollisionShapeFactory.createMeshShape().
My character uses a box for collision shape.
Oh, a box probably collides at four points, use a capsule or a sphere. The character shape cannot rotate anyway, so a box probably is not a good idea anyway.
That fixes the sliding.
I have a few more questions. Where does it place the center of the capsule?
The other way around, it places the Spatial at the center of the capsule.
Ok, so when I use setPhysicsLocation the arguments I pass to that method is the new location of the center of the capsule?
I have one more problem now though.
In some places my character falls through the floor.
I think I fixed that now.
My (hopefully last) question on that matter: The collision shape of my floor is above my visible floor, so that my character floats above my visible floor.
How can I fix this?
This is probably due to the mesh having a local translation when you generate the collision shape. Don’t have the spatial attached or translated when you generate the collision shape.
This was my problem when I fell through the floor. The floor falling is fixed with this, but the floating is not.
Can the problem be that my floor is just one quad?
Maybe your model is just floating? When you enable the debug view, does the capsule touch the ground? Also, you can just move the models children when it doesn’t align with the collision shape.
Yes, it touches the ground.
Well how ever, you manage to create an offset You have to either reset the location of the spatial before you create the collision shape or move the child Geometry in place after you created it.
Where does the offset come from though? I simply load a plane model and create the collision shape. I never move it.
How can I reset the location?
I dont know, look at the model in jMP and check if there is values other than 0,0,0 in the localtranslation… Maybe you export it with an offset already?
Does Blender screw it up then when exporting? Because I do not touch the local translation, ever. Not in Blender, not in jMP, not in the game code.