What to put as "object" in Cast node?

If I’ve understood correctly, the “object” must be a reference to that specific object I want to cast to, but I don’t really understand what to put there to cast from one actor BP to another. In my case, I want to open a door when I press a button. I have a BP_Button and BP_Door (both actor blueprints).

This is what my BP_Button looks like. I am struggling to understand what to put as “object” in the cast node.

This is my BP_Door, which is what BP_Button is trying to cast to.


Both blueprints are just actor blueprints I made myself, nothing fancy.
Any help is appreciated, thank you so much!

in order to Cast<T> on an object we need to get the Object to be cast. there are a number of ways to do this, and each one varies on complexity, redundancy, and other design choices

you can utilize an overlap collider where on Overlaps

  • lets say the Door tests for like a Player with a collider in the beginOverlap() it would Cast the Other Actor to the BP_Player then set a variable in the BP_Player to say “there is something to interact with” or " there is a Door that can be opened" along with somehow registering itself to the BP_Player. then the Player “does a thing” which fire off in your case the OpenDoor()
  • let say the Player have a collider that looks for interactables (in this case Doors) then when there is something inside that collider that can Cast to an Interactable, the Player can then issue a command to Interact() on that interactable (in this case OpenDoor())

another method is to utilize Traces of some kind, whether that be Line Trace, or Sphere trace

  • when the player hits the command a trace is performed then you go through the results and try to cast it to the given type to then call a given function on it.

there are other methods utilizing managers, but these can get very complex for moderate amounts of positives unless your design needs such.

what if I don’t have a collider, let’s say, I want to cast from the player to bp in the map, to tell the bp to execute a function, the player has no way to collide or to line trace to it so how would I go about that?

as I mentioned in the post you can utilize

a manager: a unified object that either creates the object in question, or is informed about the objects existence; then just holds onto references too them

a GetAll<T>(): where you specify the type, but this is vary dependent on how many of the “T” there are, and how often you are doing this. You are directly quarrying the World for all objects, and the world is stepping through each one seeing if it is or derived from “T” which can get heavy fast at high number of objects, or high number of results,

  • you will then need to further filter the results to get the specific thing you want.

some kind of other trace: if the object is supposed to be in proximity, then you can do like a SphereTrace, and see if the object is there (similar to LineTrace, but a stationary SphereTrace can still return false positives that need to be filtered, or potentially miss the target because it is just outside at the point of the test)