ODE collision with controlling charector

I use ODE collsion all work great
but I can’t control charector it roll to other way :confused:

please me tell some idea
thx :astonished:

charector setup code

self.ralphboxBody = OdeBody(world)
        M = OdeMass()
        M.setBox(100, 0.5, 0.5, 0.1)
        self.ralphboxBody.setMass(M)
        self.ralphboxBody.setPosition(self.ralph.getPos(render))
        self.ralphboxBody.setQuaternion(self.ralph.getQuat(render))
        self.boxGeom = OdeBoxGeom(space,0.5,0.5,0.1)
        self.boxGeom.setCollideBits(BitMask32(0x00000001))
        self.boxGeom.setCategoryBits(BitMask32(0x00000002))
        self.boxGeom.setBody(self.ralphboxBody)

Moving code

if (self.keyMap["left"]!=0):
            self.ralph.setH(self.ralph.getH() + elapsed*300)
        if (self.keyMap["right"]!=0):
            self.ralph.setH(self.ralph.getH() - elapsed*300)
        if (self.keyMap["forward"]!=0):
            backward = self.ralph.getNetTransform().getMat().getRow3(1)
            backward.setZ(0)
            backward.normalize()
            self.boxGeom.setPosition((self.boxGeom.getPosition() - backward*(elapsed*25)))

Physic Calculate code

space.autoCollide() 
        world.quickStep(globalClock.getDt())
        self.ralph.setPosQuat(render, self.ralphboxBody.getPosition(), Quat(self.ralphboxBody.getQuaternion()))
        contactgroup.empty()

Well, you can just go with setting the character’s orientation upwards in every physics update, but I would strongly advice against making a Dynamic Character Controller. As far as I’m aware, none of the physics engines that provide character control do it with dynamic body, but rather the a kinematic (and thus fully controllable and predictable) object.

Kinematic Controller may look like the more complicated way to go, but it fact it’s not. With dynamic it seems easy once it stops it’s typical rock and roll, because you think ODE will do most of the work for you, but in fact it only get’s worse. It starts to bounce, it’s difficult to keep in place, difficult to stop, difficult to make it not bump off of stuff like a ball thrown at a wall etc. It’s a mess. The Kinematic seems difficult to get started with, but once you’re up to speed with it it’s very easy to get right and, more importantly, gives you full control and very predictable results, which can’t be said about the dynamic body thing. But what you look for with characters.

Long story short - in Kinematic you focus on making it do a few things (walk, run, jump, fall, not penetrate, walk stairs and push stuff around). In Dynamic, on the other hand, you spend all your time trying to stop it from doing a whole lot of things, that bodies are usually meant to do. So it’s not easy.

My personal thoughts on the subject in another topic: discourse.panda3d.org/viewtopic … 7709#47709

Hope it helps.

thx coppertop
I must learn more for this:D
thx for your reply :wink: