Hi is there a way to ‘open a door’ by ‘pressing the E key’, which only works ‘when the player is within the trigger box’ only?
I’d say you just need to put some check logic in place on the input. Say, set the box trigger to set a boolean on overlap with the player character and put a branch on the input event that checks that boolean.
Look at my example. I think it is easy to understand.
Don’t do this in the LevelBlueprint. The LevelBlueprint should be the last thing to think about, if you do such things.
Do it inside of the Door like this:
Add the OnComponentBeginOverlap and OnComponentEndOverlap of the CollisionBox, which you already added to the door, to your EventGraph by selecting it and scrolling down until you find the green buttons on the right side:
http://puu.sh/omMoi/26aecc3847.png
And then do this:
http://puu.sh/omMBA/974b892736.png
What this does is:
Enable Input for the Door Actor when the Player overlaps (and only the Player).
Disable Input for the Door Actor when the Player stops overlapping (and only the Player).
If Input is enabled, open the Door when pressing E. I only play a sound here, because I don’t have a door at hand.
You might need some more logic, for example let the Door open completely before the E Press works again, so the Player can’t spam the button. But that’s how you Enable Input for a Door (: No LevelBlueprint needed.
NOTE This is a SinglePlayer solution. Won’t work in Multiplayer.
Cheers! (:
the links can no longer be accessed, just letting you know