How do i change ai state with ui button?

Hi everyone, I Currently have pawns that have basic movement and collision that auto spawn at start of level and auto walk back forth between 2 walls. I want to set it up so when i click on a button in the ui and then on the pawn, the pawn ai changes state eg. goes from walking to jumping. I don’t care if i have to start again…put simply i want to be able to individually control pawns when wanted with action buttons in the ui. Please help

Hi slmdzl,

I would start out by creating an Enumeration for the desired AI states. Then add a variable of this enum type to both the widget and the AI character. Then create the functionality from the screenshot within your widget event graph, and the functions(or events) that will handle the AI characters state change within that AI Characters Blueprint.

You would need to create a method of collecting the actor at the desired “Get Hit Result under Cursor” this should be handled on the Player Controller, and if you are using the Top-Down Template the “Move To” function for capturing the target location is a good place to start. Once you have the AI Character Ref from the hit location save it or pass it directly to the “Change AI State” event in your Widget. This should then fire through the switch to the correct funcion(or event) to be called on the AI Character, just remember to then set this new AI State on that character, (you could pass it in the parameters from the Widget then set it).

wow that is a great answer and mostly understand whats going on … as a self taught game maker i struggle sometimes with certain specific tasks i want to create and this is a great answer thank you very much i will try and implement asap and let you know if i get it going. Appreciate your time and effort to respond my friend

Hi slimdzl, Thanks, i know exactly what you mean. If you feel your question is answered, please mark it as resolved to assist other developers,. Let me know if you are still having problems.