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"

Triggering Events using Line Trace

Hi, quick question how can I set up two different triggers/object in one blueprint so when one of them gets hit by the line trace it runs action A and another action B?

Example: I would like to use door in two different ways. First when I look at the door handle I can do action A (open door) and by looking at the knocker I can do action B (knock on the door).

I know how to do this using overlap event but is it possible to achieve same effect using line trace?

thx in advanced.

Product Version: UE 4.20
Tags:
more ▼

asked Dec 15 '18 at 11:18 AM in Blueprint Scripting

avatar image

LordZedd_02
11 2 2 6

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

1 answer: sort voted first

hey there! you need to use an interface (https://www.youtube.com/watch?v=G_hLUkm7v44).

It's a blueprint type asset you can implement on actors that you want to be able to use it. The interface can have a pre-set function, lets call it "React", now any actor that implements the interface can place a "Event React" on their graph.

The magic of interfaces is that when you call it, and the other actor has it, it just works.

So when you trace you get a HitActor return. On that actor you call "interface call React". if the actor has the interface implemented, it'll trigger its "Event React" event.

more ▼

answered Dec 15 '18 at 03:24 PM

avatar image

Evigmae
1.7k 8 4 8

avatar image LordZedd_02 Dec 15 '18 at 05:25 PM

Hey thanks for the answer.

Actually im using an interface but probably in the wrong way. Here is my setup.

My line trace from character blueprint is hitting an actor (door blueprint) with "On Interact" function/interface.

Than my door blueprint is receiving hit and I can call an event "On interact" but the problem is that he sees door as a one object. I was trying to add another actor as a component to my door blueprint which could serve as a trigger with their own function/interface so I when its hit I could send message to my door blueprint but that didn't work either.

Im not sure if I understand how exactly interface works and that is why my whole logic is wrong. My main question is how can I have multiple actors added as a component inside blueprint.

alt text

avatar image Evigmae Dec 15 '18 at 06:21 PM

you want a Child Actor Component for that (https://www.youtube.com/watch?v=PMGwXEzfCI8)

it should work, it's a way to have a blueprint be composed of more than 1 actor.

avatar image LordZedd_02 Dec 16 '18 at 12:04 PM

Hey thanks for the link, now i have better understanding of child actors but still I can't wrap my head around it.

I have set up my "Interaction" interface, both door and trigger blueprint has it implemented. Door BP has my trigger as a child actor component. Now how can I send a message/information from trigger to door?

avatar image Evigmae Dec 16 '18 at 03:35 PM

So on your "main actor" you need to set the child actor component's Owner on begin play.

You will also need an event to be called from the child actor component.

alt text

And on the "child actor component" you can just get the owner, cast to the main actor class and call the function you made.

if you want to use this trigger actor anywhere, they could communicate using another interface function =)

alt text

A, maybe, simpler way of doing all of this would be to just have two collisions on my door actor: a main blocking one for the character, that my trace won't see. And a second overlapping one, that will be picked up by my trace. Then I would just call the interface on the main actor.

In both cases the outcome is the same. I guess you pick what makes more sense to you.

5.png (117.3 kB)
3.png (75.0 kB)
avatar image LordZedd_02 Jan 02 '19 at 07:18 PM

And now its working, thanks.

(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