在我的javascript/BABYLON游戏中,我想相对于对象所在的位置旋转对象。我有一张桌子,周围有四把椅子。我创建了这个方法,它以一个整数为参数,并根据这个值设置角色在Y方向上的旋转。
/**
* Rotates the player in Y
* @param rotY The rotation to rotate the player in the y-axis (in radians)
*/
public rotatePlayer_Radians(rotY: number): void {
var bot = this.gameObject;
var rotY_Radians: number = BABYLON.Tools.ToRadians(rotY);
bot.meshObject.rotation.y = rotY_Radians;
}
我称之为另一种方法:
/**
* Makes the player sit down in a chair
*/
private _sitOnChair(chairObj: MuveBabylon.GameObject): void {
//Rotate the player to the chair position
this.rotatePlayer_Radians(chairRot.y);
}
但结果是,角色坐着时总是面向一个方向。从自上而下的角度来看,它总是面朝上,好像它总是坐在底部的椅子上。
rotatePlayer_Radians(rotY:number):听起来这个函数要求弧度,那么为什么要在函数本身中将参数再次转换为弧度呢?