# Trying to add steering behavior to avoid collision

**URL:** <https://forums.unrealengine.com/t/trying-to-add-steering-behavior-to-avoid-collision/308789>\
**Category:** AI\
**Tags:** unreal-engine, impulse, avoidance, question\
**Created:** [March 2, 2015, 9:12pm UTC](https://forums.unrealengine.com/t/trying-to-add-steering-behavior-to-avoid-collision/308789 "2015-03-02T21:12:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![LUXO99](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LUXO99](https://forums.unrealengine.com/u/LUXO99)\
**Post date:** [March 2, 2015, 9:12pm UTC](https://forums.unrealengine.com/t/trying-to-add-steering-behavior-to-avoid-collision/308789/1 "2015-03-02T21:12:17Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![anon26705860](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anon26705860](https://forums.unrealengine.com/u/anon26705860)\
**Post date:** [March 3, 2015, 2:46am UTC](https://forums.unrealengine.com/t/trying-to-add-steering-behavior-to-avoid-collision/308789/2 "2015-03-03T02:46:59Z")

</div>

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](http://unreal-ai-tutorial.info/index.php/8-tutorial-cpp/7-t02-avoidance)

---

<div class="post-metadata">

**Author:** ![LUXO99](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LUXO99](https://forums.unrealengine.com/u/LUXO99)\
**Post date:** [March 3, 2015, 3:00am UTC](https://forums.unrealengine.com/t/trying-to-add-steering-behavior-to-avoid-collision/308789/3 "2015-03-03T03:00:57Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![LUXO99](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LUXO99](https://forums.unrealengine.com/u/LUXO99)\
**Post date:** [March 13, 2015, 5:52pm UTC](https://forums.unrealengine.com/t/trying-to-add-steering-behavior-to-avoid-collision/308789/4 "2015-03-13T17:52:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![idbrii](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@idbrii](https://forums.unrealengine.com/u/idbrii)\
**Post date:** [September 12, 2015, 12:35am UTC](https://forums.unrealengine.com/t/trying-to-add-steering-behavior-to-avoid-collision/308789/5 "2015-09-12T00:35:53Z")

</div>

[Archive of detour tutorial](http://wayback.archive.org/web/20141114100331/http://unreal-ai-tutorial.info/index.php/8-tutorial-cpp/7-t02-avoidance).
