- Home /
2D FreeForm Direction Strafe relative to Character Forward
Hello.
I'm using a 2D FreeForm blendtree for character strafe movement. I know I'm missing something dirt simple, but I can't for the life of me figure out how to correct the strafe 'direction' so it's relative to the characters current forward.
This small function takes a target world position and the character's strafe movement should be relative to his facing that position.
private void MoveToWithStrafe(Vector3 _TargetMovePosition)
{
//Get the direction to the target position
Vector3 Direction = (_TargetMovePosition - Character.Transform.Position);
// I now have a direction, but it's not taking into account the character's 'Forward'
// this can lead to the character strafing the wrong direction.
if (Direction.magnitude < 0.1f)
Direction = Vector3.zero;
Animator.SetFloat(ANIM_STRAFE_X, Direction.x);
Animator.SetFloat(ANIM_STRAFE_Z, Direction.z);
}
Can someone please remind me of the best way to get a direction relative to a character's Forward.
thanks
Comment
Your answer
Follow this Question
Related Questions
How to make the character strafe while running? 1 Answer
3D, Top Down, Twin stick, Strafing animation problem 0 Answers
iTween MoveTo 4 Answers