由于我从辅助类CharacterControl改为新类,BetterCharacterControl我注意到一些改进,例如推动其他角色正在工作,但我的主角已经开始滑过步骤而无法爬上更高的台阶.

我必须跳过上面的步骤,这不是正确的比赛方式,它应该只是走过去.旧助手类CharacterControl有一个默认的不滑动方式,只是走过几步,我认为可以通过改变我创建主角的代码来纠正它.
private void createNinja() {
ninjaNode = (Node) assetManager
.loadModel("Models/Ninja/Ninja.mesh.xml");
ninjaNode.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
ninjaNode.setLocalScale(0.06f);
ninjaNode.setLocalTranslation(new Vector3f(55, 3.3f, -60));
ninjaControl = new BetterCharacterControl(2, 4, 0.5f);
ninjaControl.setJumpForce(new Vector3f(6, 6, 6));
ninjaNode.addControl(ninjaControl);
rootNode.attachChild(ninjaNode);
bulletAppState.getPhysicsSpace().add(ninjaControl);
getPhysicsSpace().add(ninjaControl);
animationControl = ninjaNode.getControl(AnimControl.class);
animationChannel = animationControl.createChannel();
}
Run Code Online (Sandbox Code Playgroud)
完整的代码是
package adventure;
import com.jme3.system.AppSettings;
import java.io.File;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.renderer.queue.RenderQueue.ShadowMode;
import com.jme3.animation.AnimChannel;
import com.jme3.animation.AnimControl;
import com.jme3.animation.AnimEventListener;
import com.jme3.animation.LoopMode;
import com.jme3.app.SimpleApplication;
import com.jme3.asset.BlenderKey;
import com.jme3.asset.plugins.HttpZipLocator;
import com.jme3.asset.plugins.ZipLocator;
import com.jme3.bullet.BulletAppState;
import com.jme3.bullet.PhysicsSpace;
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape;
import com.jme3.bullet.control.BetterCharacterControl;
import …Run Code Online (Sandbox Code Playgroud)