Hi everyone,
I’m working on a interaction system whereby I can interact with objects differently based on an assigned Enum value.
The problem I seem to be having is getting it to work correctly with an index that basically tells it what the active object is (The last hit actor or component by a linetrace)
As you can see in this recording I am interacting with all my different items and then when I go to my drawers it starts to stop working or the index gets all messed up and I can no longer interact with anything anymore… I was thinking maybe this is because the drawers are components rather than actors so maybe I need a separate index for that I’m really not sure??
Any help would be greatly appreciated I’m so lost on this :((
My Blueprint:
Active Interactable function:
Show how references are added to your array (line trace func?).
I hate to get answers like that by myself but you should change your approach:
Using an Interface is a good idea for this but also using the ENUM is redundant and dont uses the potential of an interface.
What i would recomend:
- Define a Function like “Interact” inside of your interface. (No Idea how deep you are into OOP, but that will enforece every object that implements this interface to also implement the Funtions of this interface)
- Implement the functions for different Objects. The cool thing is that every object than has its own behaviour for calling this one function.
(for example: open/close logic for your door inside the door object)
- Call this interact function from your player, without caring about witch kind of interactable object it is.
Its very common to use this practice and will make it very easy for you to implment more interactable objects, becaus you only have to look on the one object you working and not on the “caller-object”
I can give you more details abou this aproach if you need.
1 Like