0

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.

4

1 回答 1

0

rotatePlayer_Radians(rotY: number): 听起来这个函数要求弧度,那么为什么要在函数本身中再次将参数转换为弧度?

于 2015-02-24T00:22:29.920 回答