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"

Fire an event on actor hit by trace?

Basically what I'm trying to do is a simple system, that allows me to "use" objects that I'm looking at in first person. The basics of many FPS games. I'm trying to do this by firing a trace line on my player character from his eyes and getting the hit actor. My question is - I've prepared the neccessary events on those actors, but how can I activate them with this trace? I cannot cast, because I don't know what I will hit with the trace. I'm not sure if I should use event dispatchers or interfaces.

Can anyone point me in the right direction? Basically I need a press "e" to use function, but not trigger volume based but looking at based.

Product Version: UE 4.9
Tags:
more ▼

asked Oct 20 '15 at 11:44 AM in Blueprint Scripting

avatar image

docmuerte
3 1 3 4

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

1 answer: sort voted first

You can use a blueprint interface to achiev that. Blueprint interfaces allow firing events (or calling functions with outputs) in blueprints using them. Just arrange your blueprints accordingly and use the hit results (after breaking them) to send the necessary message to the actor hit.

You can use the same principle to display messages on your hud as well, e.g. "Press E to use/open/unlock".

Good luck.

more ▼

answered Oct 20 '15 at 12:17 PM

avatar image

alperenakyuz
2k 62 24 111

avatar image docmuerte Oct 20 '15 at 05:01 PM

Thanks for the answer!

Could you walk me through this system, I'm struggling to make it work. Let's say I have a radio blueprint in the level, a light switch and a player character. I've implemented the interface to all 3 classes.

First as the player I look at the radio and fire the trace. The result from the hit gives me the actor and I fire the interface function, with the actor as an input.

How do I determine which object should be activated from there? Do I need a node that listens for certain actors or something completely different?

avatar image docmuerte Oct 21 '15 at 11:26 AM

I found that what I needed after breaking the hit was a Does Implement Interface node, to check if the hit actor uses the interface and then an interface message node straight to the function, that comes with a target - the hit actor.

This works flawlessly with multiple blueprints.

(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