No announcement yet.

Casting to an actor thats not the player or player character

  • Filter
  • Time
  • Show
Clear All
new posts

    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 ( although the casts are not working, and i can't figure out what needs to be plugged into the casts object pin. ( 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.
    Last edited by Manatee; 06-28-2018, 12:19 PM.


      I would recommend Direct Communication
      1. Door_Blueprint
        1. Create a Door_Blueprint and place it in the map
        2. Create an Event named OpenDoor
      2. Button_Blueprint
        1. Create a Button_Blueprint and place it in the map
        2. Create a Door_Blueprint (Object reference) variable and mark this variable as "Instance editable"
        3. Select the Button_Blueprint in the level and assign the Door_Blueprint instance you placed in the map (step 1.1) to the variable
        4. 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
      Last edited by GarnerP57; 06-28-2018, 04:12 PM.


        You need to get a ref to the object you want to access. You can either use Collision components or traces
        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:
        Check out my page, I'm really excited about it.

        Please check out my AI package: Action AI System Feat. Stealth
        or get it from itch