Ok, before I ask my question, I'll explain what I've got so far:
1) I've modelled a character riding a cloud. He is split into three seperate .b3d models, which I refer to in code as PLAYER_LEGS, PLAYER_BODY, and PLAYER_HEAD.
2) The mouse can be used to pan around the character.
3) Movement is relative to the direction of the camera and controlled by the arrow keys. To do this I place an invisible target to the left, right, front or back of the character, and I use deltayaw with turnentity to make the model turn smoothly in the correct direction.
I want the three parts of the body to turn to face the correct direction at a different rate (the head turns most quickly, followed by the body and then the legs) to add a nice, fluid, "twisty" feel. The code I'm using for this is:
The problem is that, because of the different rates of turn, sometimes the three seperate body parts turn in different directions to each other (for example, the head might rotate clockwise whilst the body rotates anti-clockwise). This is because each body part elects to turn in the shortest direction to the target. This looks a bit freaky. What I need to do is discover which direction the head is turning (clockwise or anticlockwise) and pass this to the body and legs so that they can all rotate in the same direction (albeit at different speeds), but I'm not sure how to do this.
Can someone help?
1) I've modelled a character riding a cloud. He is split into three seperate .b3d models, which I refer to in code as PLAYER_LEGS, PLAYER_BODY, and PLAYER_HEAD.
2) The mouse can be used to pan around the character.
3) Movement is relative to the direction of the camera and controlled by the arrow keys. To do this I place an invisible target to the left, right, front or back of the character, and I use deltayaw with turnentity to make the model turn smoothly in the correct direction.
I want the three parts of the body to turn to face the correct direction at a different rate (the head turns most quickly, followed by the body and then the legs) to add a nice, fluid, "twisty" feel. The code I'm using for this is:
;move relative to camera. TFormVector tmpMx, 0, tmpMz, CAMERApivot , 0 TranslateEntity PLAYER_LEGS, TFormedX(), TFormedY(), TFormedZ() If Mx <> 0 Or Mz <> 0 ;turn relative to movement. PositionEntity TARGET, EntityX( PLAYER_LEGS ) + TFormedX() , EntityY( PLAYER_LEGS), EntityZ( PLAYER_LEGS ) + TFormedZ() TurnEntity PLAYER_LEGS, 0 , DeltaYaw( PLAYER_LEGS, TARGET ) * .15, 0 TurnEntity PLAYER_BODY, 0 , DeltaYaw( PLAYER_BODY, TARGET ) * .10, 0 TurnEntity PLAYER_HEAD, 0 , DeltaYaw( PLAYER_HEAD, TARGET ) * .20, 0 EndIf
The problem is that, because of the different rates of turn, sometimes the three seperate body parts turn in different directions to each other (for example, the head might rotate clockwise whilst the body rotates anti-clockwise). This is because each body part elects to turn in the shortest direction to the target. This looks a bit freaky. What I need to do is discover which direction the head is turning (clockwise or anticlockwise) and pass this to the body and legs so that they can all rotate in the same direction (albeit at different speeds), but I'm not sure how to do this.
Can someone help?