Communication between task blueprint and actor blueprint

Hi Chan, you could use break points to see if the events are getting called. Select any node and press F9 to add a breakpoint. You can have a break point on the ‘SpawnActor Projectile’ node to see if it’s getting called. If it isn’t then add a break point in your task to see if it’s executing. Else if the Spawn actor is being called, then that probably means that your projectile is getting spawned, but instantly gets destroyed maybe because of some collision event with your gun or character. You could try disabling all the collisions in your projectile to see if that works. Accordingly you could adjust the spawn so that it doesn’t collide with the gun.

Hi guys, I am currently trying to make the ai character to shoot at the human player.
I have created a custom event by the name of pull trigger as seen in the 2nd photo(weapon blueprint) and in the task blueprint (1st photo ShootPlayer) ,at the end of the node i added the custom event pull trigger which was declared from the weapon blueprint .
The projectile dosn’t seem to spawn with such connections.
How do i make the AI send the signal from the task blueprint to theAIs weapon
Thanks :slight_smile:

i tried using the breakpoints,it seems that the (shoot player)task from the behavior tree failed to send any signal to the AI’s weapon.
I turned off all collision for the projectiles too,just in case XD.
Could it be the custom event is wired wrongly?
How to make an AI shoot at the player via the weapon attached ?

If your enemy is a humanoid character, to accurately represent the animations and weapon orientation towards the player, you might have to use aim offsets with the animations. But first it would be best to concentrate on the getting the projectile to spawn. Once that’s done, then you could move on to having it move in the direction of the player and finally the animation part.

If the weapon event is not getting called, then it might be because the ‘weapon task’ variable you have in the task do not contain a reference to the actual weapon. You could try out one thing. Just connect that weapon task node to a ‘Is Valid?’ node. Connect it’s yes output to your ‘Pull Trigger’ event call and the no output to a print string. If it’s printing out string, then it means that the weapon task variable is holding a null reference and hence not able to call Pull Trigger.

It appears that weapon task variable is holding a null reference ,may i know how to resolve this

Alright so that means that you will need to store a reference to your weapon actor. One way to do this is to store it in your AI pawn’s blueprint as a variable of your weapon type class at ‘Event begin play’ for that pawn.

Next you could replace the ‘Event Receive Execute’ node in your task with ‘Event Receive Execute AI’. The advantage here is that it will give you a ‘controlled pawn’ reference, which is basically your AI pawn. So now you just cast this controlled pawn to your AI pawn class, get the weapon variable and then call it’s pull trigger event.

And generally it is better to store references to actors such as your weapons in your pawn/character. Any other data like vector locations, booleans etc can either be stored in your controller or pawn or as a blackboard values. Basically outside the tasks themselves, so that you can access them from other places as well.

It works now,thank you Stormrage256 for your guidance and patience XD…
Thanks again

Glad to be of help, Chan :slight_smile: