i am trying to set up my AI to start roaming after a precise event.
I want the AI to spawn (it will be good also to use set visibility) and start roaming across my patrol path after i pick a key. I was thinking to use a branch with a bool condition “HasCharKey?” and make “set hascharkey” inside the blueprint Key, but i think i am in the wrong direction. Any idea? Maybe i should edit the behavior tree? Because my initial toughts were more focused on the step before “execute behavior tree” in the AI Enemy blueprint.
I add some print screen of what i got in mind (which obviously doesnt work):
2: Put in a Call to that Dispatcher after you Set Has Reached 2nd Floor on your overlap event.
3: Open your AI Controller blueprint. Make a variable of object type and search for SPECIFICALLY your trigger box object type, name it StartTrigger or something. Anywhere near BeginPlay, drag in that reference.
4: Drag off of the StartTrigger and make a node called “BindEventTo2ndFloorAlert”.
5: Drag off the red square, make a custom event, and run behavior tree!
You’re actually doing great! Let’s add in a few things and check something.
Firstly, let’s add an IsValid check to that first screenshot! It’ll go after BeginPlay but before BindEvent, and plug in StartTrigger to that IsValid. Off the False end of the IsValid do a PrintString to see if anything is set in StartTrigger. Have the message in print string say whatever you want, we just want to find out if the StartTrigger is being set!
Let me know if that prints when you start the game, and I’ll have more for you when you get back based on if it does or doesn’t! Either way it will get rid of your error message, but it might not fix your functionality yet.
And i get the printed text as soon as i click play. After 2 seconds it goes away and whenever i pass through my box collision, nothing happens and nothing gets printed
You’ll want to keep that IsValid check just in case.
Now you need to set a default for your StartTrigger. Here’s what we’re gonna do! With this setup you’ll be able to set each AI to have whatever StartTrigger box you’d like, so you could do this with the 3rd floor, 4th floor, etc!
Step 1: Open your Character that will be using this AI Controller. Go to your MyBlueprint area with the variables list, make a new variable that’s basically identical to StartTrigger from your AI_Controller and you’ll want to click this guy right here!
Make that eyeball open! That will let us set things per individual enemy in your level!
Step2: Go back to your viewport, find your character in your level, select him and go to your details panel. Search for “StartTrigger” and there should be a box for you to input your object. This says “Hey, this is the Trigger object I want this character to use.”
You can use the dropper to select your target object easily!
Step 3: Go back to your AI controller and SET THAT THANG! RightClick out in the open and the node you’re looking for is Get Owner (ActionsComp). It’s a special node only accessible by Components. Then go for something like so!
I think learning about Dispatchers is a something to be understood.
However, not knowing about whatever ElegantLooter is making, I am concerned, for him, that this implementation may not work as expected if level streaming is utilized for the listeners in the unloaded level may not be in the game yet and as a result would miss that dispatcher call event.
Hello vespineauto007 and thanks for your reply! Actually my level is quite small and the location where the enemy hunts the player its quite small. I am not using level streaming so i dont think i will have problems. I am currently trying to setup the tips given from Mind-Brain but i need to figure out what am i doing wrong since i cannot link the StartTrigger variable to the SET variable:
@vespineauto007 I wouldn’t be worried about it with their level size, but good catch!
@ElegantLooter this picture is in the AI Controller, right? You need to pull off of “Main Enemy Brand new” and GET the CharacterStartTrigger variable (or whatever the one on your character is named) from it. The SET needs to be your AI Start Trigger variable here in the AI controller. There shouldn’t be a “Target” pin. That’s about all that can be gathered with just this screenshot, we need more context to keep going.
I did just now! Thanks for your patience @ElegantLooter!
So what the IsValid check is checking is to make sure that you have a specific object in the scene selected. Right now you just have it set to be of the TYPE of object you want, but not the specific one. You need to
1: select your enemy in the viewport/game window itself,
2: scroll down the details window and find your “StartTriggerCh” variable.
3: click on the dropper
4: click on your Box2ndfloor Actor in the world details window. (The one I made to explain this has a static mesh but it’s whatever :P)
Give that a try and get back to me! I’ll be here for a while.
SO CLOSE! OK, try putting a Delay node with .1 as the time after the Not Valid and loop it back to the IsValid? If that doesn’t work, take it back out.
Failing that: Can you run it and give me a screenshot of the error code? The entire thing?
Also can you click on the final link in the error code, zoom out a bit so I can see, and give me a screenshot of that? Everything seems to be set right.
Hey @ElegantLooter,
OKAY! SO! We’re gonna do a couple of things.
Thing 1 is we’re gonna put in a printstring after Cast To BP_NotesCharacter and before the SetValueAsBool. Plug the Return Value into that, (it’ll convert it to a string).
Run the game and get within sight radius to see if it gives you the name of the Blackboard you’re using. If it doesn’t, there’s the issue.
If it does return your BB’s name correctly, we’re gonna delete that and move on to:
Thing 2. Go to your BlackBoard and make sure that the name of that Bool on your BB is 100% the exact same. A SPACE AT THE END CAN MESS IT UP. No fooling.
No, don’t run out of hope! Solving problems like these… you’ll be over the moon when it works!
Ok now we need to make sure the Character Controller is set to the correct one. So your enemy should be MainEnemy_BrandNew. Go to your class defaults and make sure the Controller is set to be MainEnemyNew_AI. It’ll be here in this spot.
After that, check and make sure the MainEnemyNew_AI has the BT set correctly. Because upon closer inspection, the error is saying it’s not finding the Blackboard return value off of the Get Blackboard node.
On your MainEnemy_NewAI add an “EventOnPossess” node and attach a “RunBehaviorTree” node. Now that I’m looking I don’t see one. Massive overlook on my part. Put that in and get back to me! I want to see this thing MOVE!