You are missing one line marked by red. From GetActorLocation to LineTraceByChannel "Start: pin.
You need to understand what is going on in this logic:
- TryGetPawnOwner gives you reference to the AI.
- GetActorLocation gives that AI’s location in world
- You do line trace from Start to End, so from AI’s location to 200 units under AI.
- If this trace hit’s anything (for example ground) you play sound depending on surface type. What is important you play this sound in HitLocation. So if you were starting your trace from Player’s location, it was finding ground under the player and playing sound there.
Hopefully this is understandable.
