I was wondering someone could help me out. I have a slight problem with my enemy AI line trace. The line trace works for the most part, the only problem is when the AI is on a higher or lower platform the line doesn’t exactly p
oint toward me like it’s supposed to. The only way it will point towards me is if me and the enemy are on the same level. I have screenshots of the issue.
Hey there @ShakCQNQ! What are you tracing towards? Many games solve this issue with setting up sockets to check for visibly, then tracing towards one that is exposed to the enemy.
A trace can be simple - start point actor A, end point Actor B world locations - or complex; weapon always linetrace in line with bore, then you have to align aim.
A common way to align aim is using an Aim Offset.
The output of most AOs will be decent enough to have line traces work, but have limits still because of maximum angles you can reach.
What is your situation? Share some BP or code screenshots to debug it.
Sorry for the late reply, but I think I fixed it though. I changed the target of the get world rotation from the mesh to the rifle and it now he’s shooting directly towards me.
If it works, it just because the AI is rotating/aming at the other target.
Depends on intention though. What you have now is a line trace that is always from the rifle to where the character is “looking” (rotated to anyway) forward by an arbitrary amount of units.
I’d do the same thing from socket location of rifle to socket forward vector times an arbitrary amount. Just for logic consistency. Then the aim is always in line with the rifle, which is what you really want.
At that point, the AI needs editing to allow the AO (aim offset) to work correctly. With that, the rifle will be pretty close to the enemy and still truly in line.
Then, I’d use the result of the line trace hit to pick out the actor, and adjust a different linetrace to go from the rifle to the actor (regardless of sight) with an emitter or a visual bullet that fakes the hit. If there was a hit it would always seem “right” to some extent (May pass throguh walls which isn’t ideal).