communicating with a AI controller

I’m still new to Unreal after making the switch to from Unity a few months ago and I’m trying to get my head around character creation.

I created a blueprint, added a skeletal mesh (a cartoon trex) with a blendspace to blend from idle to run etc. I created a C++ AI controller and got the character to run around a nav mesh between 4 preset points. It took a little while to work all this out, but so far it all makes sense.

Now I’m looking to add some variables to the character that I can set in the editor, but I at this point I realized the AI controller isn’t part of the character and is created at run time, so if I add a UPROPERTY(EditAnywhere) variable to it, I can’t set it until I start the game.

Because I originally created the character as a blue print, there is no C++ code for him to write a getter function.

First off, did I set this up wrong by starting with a blueprint and if not is there a easy way to add C++ code to my character that can pass information back to the AI controller?

Any hints or tips at this point would be greatly appreciated.

Put the variables that you want to set in the editor on the Character, and then onBeginPlay, have your Character get a reference to its controller and initialize the Controller’s variables.

Your blueprint character can reference and set any public UPROPERTY(EditAnywhere) vars on your Controller. But since the c++ compiler won’t see your blueprint classes, you can’t reference your blueprint character’s variables from the c++ Controller.

You could reparent your character to a custom C++ character class and add c++ code that way, but I really don’t see any need to do that.