Cast from player character BP to ai character BP?

cant find a solution for this, trying to cast from player-character blueprint to ai-character blueprint, what is the object i have to link here?

what i want to do is fire a custom event in ai-character BP when i press a key as the player or is this not possible?

1 Like

If you want to cast this blueprint to EnemyZombie1 then connect “self” to object input. But your AICharacter BP must be inherited from PlayerCharacter BP and it must be instantiated as EnemyZombie1 when created.

A cast casts to a specific class. It looks like your class is EnemyZombie1. You have to tell the cast which actor of the class you are referring to. Try making an actor variable and setting the default to whatever it is you want to cast to and plugging it into object. If you want to cast to the class, use cast to EnemyZombie1 class.

However for this type of thing I would not use casting at all. I would use blueprint interfaces, which are used to create events in other classes. Heres a helpful video on those: WTF Is? Blueprint Interface - YouTube

sorry guys im a rookie and still cant get this to work

Answer1: setting to self did not work for me, i guess it has to do what you said with inherited and instantiated, but i dont know what that means, could you explain that any further or show pics how to set up?

Answer2: i remember that i once used the interface-thing in relation with projectile and enemy damage, but that works with overlapping stuff, and as you can see i still have a target to set up that i cant figure out how to do, in the video he is working with overlapping, but in my case there does no overlap happen, i want to press a keyboard key and have that fire the custom event in the AI Character BP (to stop AI movement)

You need to learn more about BP inheritance. You can take a look at this link as a starting point.

well you can’t just say cast to or send an interface message to and not give it a target. The engine has no way of knowing which object you are referring to. If this is for testing purposes, you could make an actor variable, set it to public and then set it to the object you want to affect in the defaults section of the objects settings in the level editor. (you can’t set the default values of actor variables in blueprints, its silly.) “Does Implement Interface” and the interface message and casting needs this actor reference. (thats why you are getting errors on your cast and your message) This will affect ONE specific zombie. I get the sense you want to affect ALL zombies, so for that just use “Get All Actors of Class”, which will return an array. Use a foreachloop on the array and cast to each one or fire a custom event in each one or whatever. But to be clear, you must hook up the actor coming out of the foreachloop to the target or object of what you are working on. The engine cannot cast or use interfaces if it has no clue what actor its trying to get to.

got it working now, for each loop was not necessary, i dont know if its the best way or has other disadvantages but so far it works. thanks for your help guys

here the working setup if anyone interested

Thank you that helped a ton