Game Development Community

Circle Strafing

by Matthew Harris · in Torque Game Engine · 05/05/2006 (11:24 pm) · 2 replies

What I want to do is circle strafing.

When the user moves the mouses on the X-axis it affects the yaw, specifically $mvYaw of the Orc which makes him rotate about his own Z axis.

I want to offset the orc from a center point and have the Orc rotate around that point when the user moves the mouse on the X-xis. In other words he will be making a circle around that point at an offset. Any ideas how to achieve circle strafing this?

#1
05/06/2006 (4:48 pm)
*more info*

Given:
Center position - cenPos.x, cenPos.y, cenPos.z
Orc's position - pos.x, pos.y, pos.z
$mvYaw - Orc's Rotation in radians (I think)

Need To:
Have Orc position rotate around center position at a certain distance (offset) always facing inwards much like the orbit camera does.

Possible Solution:
Offset the orc a certain distance perpendicular to the direction hes facing

Math:
That's where you come in!
#2
05/07/2006 (5:53 pm)
Circle strafe means moving sideways while adjusting the rotation to keep aiming at the same point. That'll need some changes to Player::updateMove (in C++) with sure. You'll need to do two things:

- In the code block which calculates the player's new rotation (rot.z), you'll have to do some math so the rotation matches the angle required to lock on the offset. For an example on the math, check the AiPlayer::getAiMove() code, in the part where it calculates yaw values for making the AiPlayer lock on targets.

- In the part where the moveVec is calculated, more specifically where move->x is used to make the player strafe left/right, you'll have to use the move->yaw and the lock on offset to build up the strafe speed.