I’ll just add that if you’re creating an interaction system for objects, it might be worth looking into how Interfaces work. In short:
- the player pawn presses the generic E key
- each object implements an interface that allows it to interpret that action
- hitting E on a Bucket, a Tree or a Collectible Item yields a different result
This allows you to implement unique behaviour in the object itself. Behaviour that the player does not need to know about.
- E on a bucket flips it (animation plays in the bucket actor, set
isFlippedbool toTrue) - E on a flipped bucket, equips it
- E on a tree shakes it and makes it drop apples (play shake anim, fire up leaves particles, spawn collectible apples - all done in the tree actor)
- E on a Collectible Item (apple) adds it to the inventory (apple destroys itself)
- E on a Collectible Item if you have a bucket equipped - scoop all overlapping apples in a large radius
This way you do not need to worry about cascading Branches and checking whether the trace == apple string. You hit something with a trace and send it E, the item decides what to do with that action.