x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to press E key, when in box trigger box only, to open door?

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?

alt text

Product Version: UE 4.9
Tags:
more ▼

asked Apr 18 '16 at 04:59 AM in Blueprint Scripting

avatar image

MattStH
43 25 29 38

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

Look at my example. I think it is easy to understand. alt text

more ▼

answered Apr 18 '16 at 09:20 AM

avatar image

StarFlame
63 3 6 9

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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:

Functions

And then do this:

Code

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! (:

more ▼

answered Apr 18 '16 at 01:00 PM

avatar image

eXi
6.8k 332 184 465

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered Apr 18 '16 at 07:10 AM

avatar image

Raistlin-
105 5 7 15

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question