How to maintain a certain distance from a character

I have two separate actors. I can define my situation in two different approaches.

  • All I need to maintain the certain distance of player actor from other character while moving sideways (Its a dual fight).
  • The character player will be movable only to the sideways in a circular path.

Any idea how to achieve this?

hey there,

well you could try this approach:

first you know that the distance between both actors can be considered as a radius which originates at one of your actors.

What you want is a new vector which has the same length as the radius but with altered plane values.

So you have:




Vector YourPosition;
Vector HisPosition;

Vector Radius = YourPosition - HisPosition;

float Angle = InputScaleValue; // The Value from your keymap

float newX = cos(Angle) * Radius.Length;
float newZ = sin(Angle) * Radius.Length;

// XZ Plane should be the horizontal plane aka the ground youre moving onto

Vector NewPosition = (newX, 0, newZ);

SetLocation(NewPosition);



I dont think this will be “THE” solution, but i guess its a start^^ (its even not tested :smiley: )

regards