gpt4 book ai didi

javascript - 使用 Babylon.js 的 Angular 色移动

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:45:51 26 4
gpt4 key购买 nike

在我准备上学的游戏演示中,我需要使用 W-A-S-D 键和箭头键移动我的 Angular 色。我设置了一个函数并设置了一个开关盒来监听任何按键。这是我的代码片段:

//Handles the player's movement
var PlayerMovement = (function () {
//Constructor
function PlayerMovement() {
this.gameObject = null;
this.movementSpeed = 0;
this.rotationSpeed = 0;
}

PlayerMovement.prototype.awake = function () {
console.log("Awake");
};

PlayerMovement.prototype.update = function () {
//console.log(Tools.getFps());
}

PlayerMovement.prototype.onKeyPressed = function (key) {
switch(key)
{
case KeyType.W:
case KeyType.UpArrow:
console.log("Moving up");
this.gameObject.meshObject.position.z += (BABYLON.Vector3.Up() * this.movementSpeed * Tools.getDeltaTime());
break;
case KeyType.A:
case KeyType.LeftArrow:
//TODO: Do stuff
break;
case KeyType.S:
case KeyType.DownArrow:
//TODO: Do stuff
break;
case KeyType.D:
case KeyType.RightArrow:
//TODO: Do stuff
break;
}
}
return PlayerMovement;
})();

我的问题是我的 Angular 色跳得太远以至于他从屏幕上消失了。谁能帮我弄清楚我的计算有什么问题?

最佳答案

一些事情-

关于javascript - 使用 Babylon.js 的 Angular 色移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27571362/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com