Hey everyone, I’m a student trying to learn Unreal.
I’ve been trying to understand how to target certain class objects when you’re calling a function of theirs in another blueprint. For instance, if you’ve implemented a function in the game mode event graph (via a blueprint interface), you have to target the game mode when calling that function from another class blueprint.
What do I do if I’ve implemented a function in a character blueprint? I’ve made a BPI for that character and implemented the function, but I’m unable to get a reference to the object when I’m calling that function from another class.
There is many ways to get a reference.
You have to be more specific about your set up…
If you’re trying to get a reference of the player Character in a SinglePlayer context, just “GetAllActorOfClass”(PlayerClass) and “Get Copy”(0) should be good.
In a multiplayer context, you’d have to think more
Hey again Silik. Thanks for stopping by to help. I currently have an Enemy class with a Damage function, which will reduce the enemy’s HP by whatever input is provided to it.
I’ve also got a Spell class, which has to call this function each time it collides with an Enemy. What would you recommend for this?
Yeah I accidentally left out the Get Class node. My bad.
Also, I just realised one more thing. All my spells have different kinds of colliders, but I want my parent class to handle the damage dealing functions upon colliding with my enemies. How would it be possible for me to do that? My root component is just a scene, and if I add a collider to my parent class, the child classes will have it too, which I don’t want. I can’t think of any workarounds for that either. I’d have to have the collider in my parent class to handle collisions if I want my damage dealing functions invoked there, right?