Announcement

Collapse
No announcement yet.

Require Actor that Implements specific Interface?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Require Actor that Implements specific Interface?

    So I want to have a door that needs a key to be opened.
    I could make a general door blueprint which asks for a specific key item in order to open that door.

    But that wouldn't be very reusable and that's what we want to go for in the end right?
    So I thought "I can make the required item an Actor and then ask if the item implements a specific interface." but this means I would still have to cast the item to the desired key to check if the player actually have the required item. This is not very efficient and tedious to implement.

    I tried making the required item an Interface but of course that didn't work either. So I was wondering if I could make the required actor (as in, the constructor like a property) be an actor that implements a specific interface (I_Inventory)?

    #2
    The door can try calling your Interfacefunction on whatever it gets the event with. It will fail if the object doesn't implement the interface, and call it if it does. Have your keys implement the Interface. You could then put a variable in the object, like a number that the door checks for, to see if it's specifically the right key as an example.

    https://docs.unrealengine.com/latest...ces/index.html

    Comment


      #3
      Originally posted by mikepurvis View Post
      The door can try calling your Interfacefunction on whatever it gets the event with. It will fail if the object doesn't implement the interface, and call it if it does. Have your keys implement the Interface. You could then put a variable in the object, like a number that the door checks for, to see if it's specifically the right key as an example.

      https://docs.unrealengine.com/latest...ces/index.html
      Oh right, okay. Didn't think about that.

      Comment

      Working...
      X