Download

How can I make my character move in a circular path using C++ code?

Hello everyone,

I need a library where I can find the C++ code required to move a character into a circular path. Please how can I do that?

There are several ways, The first would be that you create your own code that adds the “movement inputs” for that behavior in the AI controller, calling AddMovementInput and so on. The other is doing a series of “Move To” calls, in a circle shape.

How is the character going to move circular? Is he going to face a certain direction? Is he going to move like a car on a roundabout?

I want it to orbit around another character CCW direction.

some time ago i do that for other kind of thing, but the principal is the same, i create a splinecomponent, in editor set the shape and manipulate my camera from code, you have spline length and a way to get a world location point in that spline so if you multiply some lerp by the length and then get some point in the spline is easy to do

some like this pseudo:

float lerp = //some value between 0 and 1
float distance = spline->Length * lerp;
FVector point = spline->GetLocationAtDistanceThrowSpline(distance) // jeje i dont remenber the name of this function just check in members of the spline

its all, hope helps