Trying to add steering behavior to avoid collision

Hi everybody,
I’m trying to add a repulsive force to avoid collision between my AI agents. I have a static mesh in front of my AI character that computes the overlap with another character. If there is overlap, I change a variable in the controller to let it know about the overlaping, to make the calculations. Inside of a function in the controller, I’m making a test calculation to see if something happens, but I can’t change the velocity of the characater to apply this force.
I was searching how to change the velocity of the character using the computed force, but I didn’t find how to modify the velocity of the character.
Inside of CharacterMovementComponent I found that you can apply a force or an impulse, but as I’m trying to do it in the controller, when I get The Pawn I can’t not apply this force or impulse. I made a Cast of the pawn movement component to a character movement component and then I can access to the functions, but anything happens…

Actually I don’t know if I’m focusing the solution in the wright direction… Is the first time I work with Unreal Engine and I’m a little bit lost about how to work with it.

Thank you very much!

Hi dzeligman,

I know that Unreal has its own avoidance system, but I’m making a project in university where I have to achieve collision avoidance with Unreal 4… This is why I’m trying to do the steering behavior… I have done one very rough hardcoding the values, but now I have to program another a little bit more complex…

I’d recommend using the built in solutions instead of rolling your own. Unreal has two built in solutions for avoidance. The first uses the AvoidanceManager and is a simple RVO avoidance based algorithm. The second is a partial port of Detour crowd. More info available here

Just to let someone know if is searching something related with my doubt.
I used the function MovementComponent::MoveUpdatedComponent(FVector Delta, FRotator NewRotation, bool Sweep) inside the Controller of the AI character to give it a delta velocity that I calculate in order to avoid the agents I detect it has in front.

Archive of detour tutorial.