Skip to main content


Showing posts from July, 2017

AI Controller - Final update

I got the sample level up and running - and I'll let my video do the rest of the talking! :)

AI Controller Update - Week ending 7/18

This was another landmark week. I was finally able to get navigation meshes working with all the behaviors I’d implemented so far. To see how important this is, let’s consider an example: The follower (the smaller model) needs to get to the target position (the other character in this case). However, there is an obstacle in between. The steering algorithm doesn’t know anything about obstacles. So it will continually push the follower towards the actor, and into the obstacle. With a navmesh, we can tell the steering algorithms to follow a sequence of points in order to reach the target actor. Now, calculating this every frame is very expensive. So what do we do here? First, we raycast to the target position to see whether the follower can reach there uninterrupted. If it can, fantastic. We just ask the follower to seek to the target position. If there isn’t a direct path, we request the navmesh to provide us with a set of points that we store, and then seek to one by one. Wh

AI Controller Update - Week ending 7/11

This week I worked on improving finding cover objects. The first thing I did was to go back and tag all the cover seekable objects as such. Without this, the problem is that objects such as walls and such might be detected as cover objects as they satisfy the width and height requirements. Then, I stuck with the sphere trace implementation where a sphere cast would be performed to find the closest cover object. I compared the tag and found the closest one. Then, I changed the implementation to use Seek rather than Arrive, as realistically one wouldn’t slow down going into cover. This also removed some visual artifacts I was having with very slow movement over small distances with Arrive. The updated code to find the best hiding spot looks like this: if ( UKismetSystemLibrary :: SphereTraceMulti (               GetWorld (),               pOwner -> GetActorLocation (),               pOwner -> GetActorLocation (),               CoverSearchRadius ,               TQ

AI Controller Update - Week ending 7/4

This week, I worked on Obstacle Avoidance and a slight hint of navigation. Obstacle Avoidance Though the concept is simple enough, the execution is quite tricky. The first part is to detect obstacles in your area. We define a lookahead, which can vary based on the object’s current velocity. I’ve left it at a fixed value for now. Then we raycast forwards to find the first obstacle in our path. Next, we compute the normal from the point of impact. We steer our object away from the point in the direction of the normal. The code looks like this: bool bHit = GetWorld ()-> LineTraceSingleByChannel ( Hit , StartLocation , EndLocation , Channel , QueryParams , ResponseParam );        if ( bHit )        {               FVector PenetratedAlongHit = Hit . ImpactPoint - EndLocation ;               FVector PenetratedAlongNormal = PenetratedAlongHit . ProjectOnToNormal ( Hit . ImpactNormal );               float PenetrationDepth = PenetratedAlongNormal . Size ();