I’m following tutorials on YT by Ali Elzoheiry ( Link to the playlist ). When I set some very basic AI that makes the opponent chase the player, it was working as intented. But when I got to the AI states and added ‘chase’ and ‘attack’ state, the enemy stopped reacting to the player’s character. In the current state, the enemy does an instant 180 rotation and keeps shooting at nothing.
My project has four selectable characters, all of which are parents to the default character BP with the only difference being the color texture and internal name (main character BP is called ‘BP_PlayerBase’ and one of the parents is called ‘BP_BlueGuy’ for example). I’'ve made a separate map with all four character templates and the interface for character selection. Each map has an empty actor that serves as a spawn point for the player and there’s a placed enemy actor.
I basically wanna create a basic enemy AI that would chase the player, circle around them in random directions while shooting, and retreating when it decides it’s low on health or energy. Both the player and enemy have the same ranged attack with the same structure. I’m not aiming for super advanced AI because it’s for a college assignment (if you’re wondering, no, they did not teach us how to create stuff with blueprints or any coding language).
How can I at least make the enemy react to the parent actor?
Here are screens on where I’m currently at:
I know you say to ignore it but It’s not just that you have the bottom half of your first screenshot disconnected is it? There’s nothing that I can see that defines your character base bp as the attack target within the blackboard key.
I’m following the same tutorial currently and he starts with that section connected so that the player is always the attack target. But disconnects it when creating more complex logic to determine the attack target.
This is what he said I should do earlier in first video. When I started doing all the AIC, BT and BC, the enemy did chase the player. It’s when I started adding tasks and states it breaks.
If I just had the basic BP_Thirdpersoncharacter, it wouldn’t be an issue. But since I’ve made four parents of one character BP, the AI just breaks. Like, why can’t the enemy just attack the player just because it’s being controlled by the player?
Using “Get player pawn” and setting that to the Attack target blackboard key would do exactly that, even on your separate player character BP.
Try putting the delay back in and the setting of the attacktarget key. When you get to AI perception, that’s when you would take this bit out and call it from another function when your player is spotted.
I’ve replaced ‘player character’ nodes with ‘player pawn’ but now it just functions like a turret. It knows where my character is, even behind obstacles and never stops firing. Even if I change the decorators on the BT didn’t do anything.
Unless I’m mistaken that would be the expected behavior at this point. If you added a troubleshooting keyboard event that would switch the State between chase player and attack player you would be roughly at the end of the second part of that tutorial series. Part 3 would then add perception to the enemy so that they need to see the player to attack and would check out the last point of contact etc.
Well, I did add sight and damage senses to the AI and once I got in its sights, it stopped attacking completely. When I checked the BT, it was set to Chase Player but it was rapidly switching between ‘stop sense’ and ‘move to’ tasks, while not moving from its place.
I’m sure that I’ve messed something in the sequence order, conditions or something else entirely.
Does your Chase sequence decorator have an abort on result change and do each of your custom tasks within the chase sequence have an abort event?
Both decorators are set to abort themselves, with chase sequence being set to equal ‘Attack State’ and attack sequence set to equal ‘Chase State’. The attack and focus tasks don’t have the abort event.
Im not sure what else I can suggest other than to go back over the tutorial. I don’t think I’ll get anywhere without being in front of the project considering it’s a few different BPs and interfaces all interacting. Sorry
The one thing I can say from your last comment, why is chase sequence set to state attack and attack sequence set to state chase? unless you have the decorators inverted you’ll get the opposite behaviour expected and even if that’s true it’s counter intuitive.