如何走楼梯和斜坡? [英] How to walk stairs and slopes?

查看:289
本文介绍了如何走楼梯和斜坡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用jme3并与BetterCharacterControl一个问题是, setMaxSlope 未实现。该引擎的开发者说,我们可以使用新的控制器解决它自己:

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:

<一个href="http://stackoverflow.com/questions/16782375/how-to-improve-character-control-for-my-3d-game">How以提高角色控制我的3D游戏?

你能帮助我们进步?我录一个视频的问题:

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

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

有些文档是在这里: http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:walking_character?s[]=bettercharactercontrol#bettercharactercontrol

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;
    }
}

但上面没有做任何改变,或者如果我设置的高度为101,然后它变得难以移动的游戏角色。你能不能帮我们看看应该怎么做?

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?

推荐答案

由于运动对待字符作为 PhysicsRigidBody PhysicsJoint S,有可能是没有足够的向上魅力在他的腿或膝盖。但愿这些参数只是没有设置,以适应楼梯的尺寸。

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.

既然你有最麻烦与导航倾斜的楼梯,次要的措施可能是调整走的方向。我怀疑你可以依靠 location.equals(lastlocation),但在短距离内是一个很好的检查,看看是否字符碰到了一个障碍。一旦你知道有要清晰地缩放或保持低于卡住了一步。

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.

这篇关于如何走楼梯和斜坡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆