0
在我的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);
}
但结果是该角色总是面临着一个方向它位于时候。从上往下看,它总是朝上,好像它总是坐在底部的椅子上。