I’ve followed & completed Epic’s Behaviour Tree Quickguide and my next step is to create AI more specific to my needs and I’ve hit a snag.
I want enemy perception to be based on Line of Sight and assume this needs to be broken down into three stages.
The first is a radius check between the enemy character and the player’s character.
The second is a check to see if the player character is within the enemy’s vision cone based on the direction the enemy is currently facing.
And the last check is a single line trace to the player’s character to see if they are being obscured by anything.
Parts 1 & 3 are working, but I don’t know how to ge the angle from the enemy character to the player character based on their locations and the enemy character’s rotation.
Does anyone know of the best way of handling this step?
[UPDATE] Ok, I’ve nailed that after just trying lots of different functions related to rotation, and now I’m stuck at the Line Check.
Does anyone know how to trace a line between two specfic actors, rather than channels or objects? Or do I have to create a custome object type, such as PawnPlayer and use that?
Now I’ve hit my next snag.
I’ve created a custom Trace channel for LOS Line Traces called ‘Player’. The player and environment will block this by default.
However, the Line Trace from the enemy is ending almost immediately and complaining that it is colliding with the object ‘CollisionCylinder’. I’m printing the info of whatever the Line Trace hits onscreen to confirm this.
Now I’ve set all parts of the enemy (body mesh, weapon mesh etc) to be ignored by ‘Player’ traces, including the CapsuleComponent.
Considering that ‘CollisionCylinder’ and ‘CapsuleComponent’ aren’t the same name is there a chance that they aren’t the same thing, or that there is something not obviously exposed that I should be dealing with in the blueprints to disable the CollisionCylinder’s collision?