Casting to an actor thats not the player or player character

What im trying to do, is when a button is pressed, the button tells the door to open if the button link and door link are the same int (https://cdn.discordapp.com/attachments/410828445543563285/461910293052784641/unknown.png https://cdn.discordapp.com/attachments/410828445543563285/461910371121496065/unknown.png) although the casts are not working, and i can’t figure out what needs to be plugged into the casts object pin. (https://cdn.discordapp.com/attachments/410828445543563285/461910087393345536/unknown.png https://cdn.discordapp.com/attachments/410828445543563285/461910229232386054/unknown.png) Im trying to do it with the links so i am able to get multiple buttons and doors on one level, without 1 button opening all doors, and without needing to duplicate them.

You cant cast directly from an actor to another actor, which are separate entities in the level. You will need to do the logic around a common ground they both share-, level blueprint, player character, or gamemode. The door actor doesnt know that the button exists, this is why you cannot make references of each otheir either.

You could use the door actor to “spawn actor” “button” to the level when the game starts as his child object, and then reference to the button from the door actor, but I would recommend using just the main blueprints to control this. Otherwise you will be in a chaos figuring out which blueprint controls what, when levels get more complicated.

Since they are objects on the level, the most logical place to do casting and handling the operations would be the Level Blueprint. From there you dont even need to use cast nodes, but simply by drag the objects fom the World Outliner into the Level Blueprint. Then you can read/write variables withing the 2 using the level blueprint.

I would recommend Direct Communication https://docs.unrealengine.com/en-us/…BlueprintComms

  • Door_Blueprint

    • Create a Door_Blueprint and place it in the map

    • Create an Event named OpenDoor

  • Button_Blueprint

    • Create a Button_Blueprint and place it in the map

    • Create a Door_Blueprint (Object reference) variable and mark this variable as “Instance editable”

    • Select the Button_Blueprint in the level and assign the Door_Blueprint instance you placed in the map (step 1.1) to the variable

    • In the EventGraph get the Door_Blueprint variable and use it to call OpenDoor when the button is pressed eg.

If the button needs to open several doors simply make the variable into an array and use a foreach loop when calling OpenDoor

You can place as many instances of buttons and doors in the map as you like. Link the button instance to the door instance as described in step 2.3

You need to get a ref to the object you want to access. You can either use Collision components or traces https://docs.unrealengine.com/en-us/…To/UseRaycasts.
Either will give you information of the object it hits so you can cast to it and access it’s parts.

Here is a tutorial: