How to reference a spawned character?

I have this simple script in Level BP which correctly spanws an enemy when I collide with a simple TriggerVolume:

As you can see, I dragged a wire out SpawnAIFromClass Return Value in order to create a reference to the enemy promoting it a new variable (called Enemy). The problem is when I try to drag the wire from this variable, because I have no access to the variable of the BP class “TheWanderer”, since the autocompletion gives me no variables belonging the TheWanderer BP class.
Am I doing something wrong? How can I correctly reference this?
Thanks.

What is the Class type of the variable Enemy? This information is needed to give a complete answer to this question :slight_smile:

The variable is an INT in this case. But I don’t think it makes the difference because once you reference the character you can get whatever you want.

If you found that this answered your question please Approve the answer so that more people can find it in the future :slight_smile:

Thank you very much, it worked!

I realize I never put this as an answer :slight_smile: ohwell

What? The variable seen in the photo is an INT? Then that is your problem. If you set your spawned AI Pawn to an int, which shouldnt be possible, you will never be able to see the class specific functions for theWanderer. INT and theWanderer is not the same class and will therefore not work. The Enemy variable should be of type theWanderer, or some generic Enemy class, or just a basepawn class, you couls go as far as having it as just an actor even. If you set the enemy variable to a generic type like actor, you can always use the cast to function.

Drag from the enemy variable a line, type cast to thewanderer and it should give you that as an option. From the cast node you now have a reference to an object that have all the functions specific for a wanderer. I can include pictures tomorrow for further clarification!

You can convert a comment into an answer.