Object / Actor reference explanation

Can someone explain to me how to use object reference correctly?

  • Lets say i have an Enemy BP and a fireball BP, both are from different classes
  • I want to be able to have a reference to Enemy BP that i can access from fireball BP
  • I need the reference so that i can use it to tell Unreal that i want to do things like get enemy location, get enemy rotation, get its velocity, get what its eating, get who the enemy is sleeping with behind fireball’s back, etc. You know… the usual stuff.

The way i thought i could do this is by making a variable EnemyRef in Enemy BP and making it public.

Then using Get EnemyRef in fireball BP and use its pins to do amazing things. But in reality this is what happens:


But i dont know what connection to make to Target so here i am wasting your time asking… HELP ME BROTHER.

You need some way of telling which enemy you’re talking about. Do they have an ID like an integer of something?

PS: You’re going the wrong way with the target node there, it usually appears automatically when you drag a pin from a reference. I don’t think you can reverse engineer it…

EDIT: If there’s only 1 enemy, then you can just say:

Thanks for the reply. You are great as you may know.

Yes i only have one actor and destroying actor is not the problem. I just wanted to see how to use object references in other blueprint properly.

But i realise you cannot use it like that and using object reference variable made in one blueprint but used in another is not the right way of doing things. A better method would be appreciated.

Hi - If you need an object reference to BP x in BP y, there’s only a limited number of ways of doing it.

  1. Like I did above, get all actors of class ( or get actor of class )

  2. Just make a variable of the correct type and set it up in the editor


After that you have other ways, but they don’t use references. Things like blueprint interfaces:

and event dispatchers:

When you press x you need to pass the enemy you want to destroy.

All the actors in a game are blind, and are not able to see other actors.

For this the actor has several options
The easiest is “Get Actor Of Class” that goes through the scene just like you would in the world Outliner

You can also use a trigger and see who is in it.

Other options is to make the other objects visible to him. Like in begin play they look for the player with “get pawn” and they are added to an array.

Thank you for the feedback i will try it all out. I don’t the flow of information to stop so anyone else with ideas please keep posting.