5

We use jme3 and a problem with the BetterCharacterControl is that setMaxSlope is not implemented. The developer of the engine says that we can solve it ourselves using the new controller:

http://hub.jmonkeyengine.org/forum/topic/setmaxslope-for-bettercharactercontrol/

And I would really like a solution since my game needs it. I asked about it before but we didn't solve it:

How to improve character control for my 3D game?

Can you help us progress? I've recorded a video with the problem:

http://www.youtube.com/watch?v=PF_UzoOXD0E

Some documentation is here: http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:walking_character?s[]=bettercharactercontrol#bettercharactercontrol

My effort to add the functionality to the controller:

package adventure;

import com.jme3.math.Vector3f;
import com.jme3.bullet.control.BetterCharacterControl;

public class GameCharControl extends BetterCharacterControl {
    protected Vector3f lastlocation = new Vector3f();

    public GameCharControl(float x, float y, float z) {
        super(x, y, z);
    }

    @Override
    public void update(float tpf) {
        super.update(tpf);
        System.out.println("location " + location);
        System.out.println("lastlocation " + lastlocation);

        if (location.equals(lastlocation)) {
            System.out.println("update2");
            this.setHeightPercent(101);
        }
        rigidBody.getPhysicsLocation(location);
        applyPhysicsTransform(location, rotation);
        lastlocation = location;
    }
}

But the above is not making any change or if I set height to 101 then it gets difficult to move for the game character. Can you help us see what should be done?

Community
  • 1
  • 1
Niklas Rosencrantz
  • 25,640
  • 75
  • 229
  • 424
  • 1
    okay I have zero experience on this but maybe my simple vision could help, I would suggest setting up a slope from the edge down, so it would look like he's not jumping up at the stair. In order to do that you have to know if a stair is nearby in a some bigger radius – Dediqated Sep 12 '13 at 18:05

2 Answers2

2

Since movement treats the character as a PhysicsRigidBody made of PhysicsJoints, there probably isn't enough upward oomph in his leg or knee. Hopefully the parameters there just weren't set up to accommodate that size of stair.

Since you had the most trouble with navigating an angled stair, a secondary measure might be to adjust the walk direction. I doubt you can rely on location.equals(lastlocation) but within a short distance is a good check to see if the character ran into an obstacle. Once you know there is a step you want to scale it cleanly or stay stuck below.

clwhisk
  • 1,805
  • 1
  • 18
  • 17
2

Why not use KinematicCharacterController which has setMaxSlope implemented?

Not sure which JME you are using, but here's the source to that controller:

https://code.google.com/p/jbullet-jme/source/browse/branches/jbullet/src/com/bulletphysics/dynamics/character/KinematicCharacterController.java

ClickerMonkey
  • 1,881
  • 16
  • 13
  • I'm not sure but I think it might be too old and deprecated. The jme3 developer said in the forum that we should work on the BetterCharacterControl and add the setMaxSlope method to it, but it is difficult. – Niklas Rosencrantz Sep 15 '13 at 00:43
  • 1
    You're probably right, I couldn't get the KCC working on a game of mine anyway... it might have been me or maybe the code is flawed. I just gave up trying to use it and did my own collision detection (luckily my game was "simple" enough that this was plausible). – ClickerMonkey Sep 15 '13 at 04:36