Using LineTraceByChannel For multiple Objects

I saw a tutorial on how to open/close a door, I followed it and it worked. But now I want to use that same system on another door (slide door). Which also works when done sepperatly, but I can’t figure out if/how it is possible to use the one LineTrace to execute 2 different actions based on which object gets hit. Since it doesn’t seem possible To get Two lines out of the Exec of the Linetrace. I also tried to just make 2 line different line traces on MouseClick but here there is the same issue, that it can only have one line out from the mouseClick. And I would Really prefer to have it all on one Button.

My setup now :

You need a blueprint interface for that:

  1. Blueprint Interface | Unreal Engine Documentation
  2. Implementing Blueprint Interfaces | Unreal Engine Documentation
  3. WTF Is? Blueprint Interface - YouTube
1 Like

Just connect the cast fail from the sliding door to the sliding door input. That should work. Or you could make an Enumeration with a list of the doors then have a switch on enum that is connected to a the Enumeration variable in the door blueprint. Or your could make an integer variable in the door blueprint and use a switch on integer to decide what door your using.

1 Like

Just connecting the Cast Failed to the other input did indeed work. Thank you for responding

No problem, it is the quick and dirty way though. I would suggest learning and using the Blueprint interface option. It is more complicated but it has huge advantages especially for more complicated interactions. Also I think its quicker and uses less processing then the casting method. An example is if you have a parent object for all doors drawers openings and all sorts of things of that type and have a large amount of them, instead of casting to each object every time, it would seem to be better to use a blueprint interface. But for 2 or 3 different doors or a demo then casting would be fine.

Yeah that makes sense, I am completly new to unreal so I just took the firs tutorial that seemed decent and used that. Right now its just looking for 2 different types of doors, which in total might count 10-20 in the scene. Doesn’t seem to cause to many problems, but will definetly look for a better solution once i understand things better. Probably like how most games have it to just press E when looking at a door with a little popup.

:melting_face:

1 Like

It would be better if you learn inheritance first before getting into interfaces, it’s easier for simple problems

I went through the video and it was generally really usefull, but it had a section with what I was trying to do. done with the blueprint interface starting at about Blueprint Communications | Live Training | Unreal Engine - YouTube . So for anyone stumbling on this topic and looking for how to do it, this is probably the way