In my javascript / BABYLON game I want to rotate an object relative to where it sits. I have a table with four chairs around it. I created this method that takes in an integer as a parameter and sets the character's rotation in Y based on that value.
/**
* 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;
}
And I am calling it on this other method:
/**
* 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);
}
But the result is that the character is always facing the one direction when it sits. From a top down perspective it is always facing up, as if it is always sitting on the bottom chair.