TraceLiceByObject Affecting the wrong Actor

You missed all the important information in your screen shots. We need to see where the “M2” variable is set, and more importantly…how do you go from setting a boolean variable in the PLAYER character to moving a Door with a timeline? What function or events are you calling? How do you access the door? You kinda missed the whole point of the line trace by not using the “hit actor” to do anything. You are only using the boolean to check if a hit occurred which throws away a lot of good data from that trace. You should be using the “Hit Actor” to call a function within the door or change some variable in the door BP itself. Whatever you are doing is not efficient and a roundabout way to communicate with the Door BP. Post some more screen shots and this will be an easy fix.

Hi everyone,

I’m facing an issue with my FPC Blueprint against a Door Blueprint.
The thing is that I want to be able to open doors with the E key when a traceLineByObject hits the door.
I tried to set it up but what I get is that whenever I hit the door with the line and then press the E key, it just opens ONE door actor (I have the same BP spread along the whole level), and it is the first BP of this class (the first one I placed in the level) but I just want to open the one I’m hitting with the LineTrace.

I wish it’s an easy question ! Anyway I’m uploading some screenshots of my blueprints set up:

With this set up everything work fine except what I said, when I press the E key when hitting an actor it opens always the same door (the 1st one I placed in the level. All doors are copys of the same DoorBP) and just that single one.

Here you see I hit a door and the values of rotation change nicely but just opening the wrong actor…

Any help coming here would be super appreciated!! Thank you so much!

What Triggers your timeline?

You have to use “Hit actor” in the “Break hit result”, cast it to your door blueprint and command it to open. How should the engine know what door to open? It’s your job to show it via your blueprint.

Alternatively to casting you can create an interface.

I’m sorry, I’m in learning process about Blueprints so my screenshots were super bad explained and selected.

  • The M2 variable (the door object) is just a reference to the Static Mesh I added to the BP which is the door itself so that what I use in the Timeline.
  • What I tried to do is just to trigger the Door Timeline with the TraceLine, so whenever the HitActor is true, the Door TimeLine triggers. So I just referenced the Variable HitActor from the FPC BP to the DoorBP to use it to trigger the whole thing.

So as what Nebula Games said this is not efficient because I’m not calling an specific actor (in this case the exact door the player is pointing to), just calling any when the HitActor variable is true, right?
So I think my issue is that I don’t really know how to modify the Hit Result or what function should I create or connect in order to get the correct door to move.

I tried to clean up a bit both blueprints, FPC and DoorBP to try showing you better all what I have. Let me show you now!:

This is just all I have in the DoorBP.

And as I sent in my question, this is my FPC. So what should I do to modify all of this in the right direction?
Thank you so much for your answers guys!!! I appreciate it a lot!

Drag the Hit Actor from the Break Hit Result pin and type Cast to your door blueprint name. After you cast it, you will have access to that blueprint functions, and from the Cast node you drag the output pin and type in the name of your function, “open door” or whatever you have there. The trace you use has already found the actor in your world, you only have to indicate what to do with it.

Another thing: is your door’s collision type really a “vehicle”? Because you only trace Vehicle with your Trace Line.

Thank you so much for your answer Tuerer!
So how should I call the specific Door I’m pointing to with the TraceLine throughout blueprint?
I need to learn a lot yet about Blueprint stuff!
I guess it has something to do with the Break Hit Result but I don’t really know how can I modify it.

Yeah my Doors are all set to Vehicle so I’m able to hit them all!

On the other hand, I’m trying what you say… but it’s not working because for moving the doors, I’m using a Timeline and I cannot call it from the FPC. So I’m now trying to assign tags and create an Array for all the doors but I cannot get it… how should I?

This is what I have so far:

So I’m trying to assign a tag to the Actor I hit with the Trace so then I’m trying to store them in the DoorBP and then call that Actor from the array to execute the Timeline… But it’s not working and don’t know if I’m getting closer

You should not get all the doors in the door BP, and you definitely must not use Foreach loop in your Door BP. Set one opening function for only one door (self) in the door BP. Each door in your level will implement the door BP separately just for itself.

You don’t need to create door arrays here. Each individual door is referenced in the hit result when it’s hit by trace.

Probably I’m being stupid but… I don’t get it. I deleted the for loop and forgot about the array stuff, okay till there. But I already created a function in the DoorBP with a Timeline (screenshot above) and moving just the component of the BP that I need.
like this:

When the Line hits any Vehicle Actor, it works okay (I mean the hit works properly) and also the input, but still it just opens one door that is not which I’m pointing to with the Trace…

Alright.

First, what you need in the door BP is ONLY the open and close function with the timeline.

Second, E key should be in your character BP. By pressing E you activate the trace line and everything that follows.

Third, you should never use Ticks with Casting. Casting takes lots of resources, and doing it every frame is not good.

Okay, I did what you said. In the DoorBP there’s now just the Open Door function. What I did is create a Custom Event to call it once I finish the LineTrace. Is it right?
This is what I have:

I have it like this. I don’t if this is what you mean but now the doors don’t open… probably I’m missing something?
And in the FPC I also set the E key, but same…

Okay, it’s fixed!! it wasn’t working just because somehow the other doorBP were creating conflict with the E key. I just changed the Input to LMB and now it works.

THANK YOU so much for helping me Tuerer!!! It was super helpful!!

Yes, that’s exactly what I meant. Now if it doesn’t open you have to trace the execution sequence and see where exactly it stops. Try doing it with opening only (remove that flip-flop for a while). Launch the game in separate window and look at the execution nodes in your character and door BPs as you press E. You will see how it goes and where it stops, then you’ll know where the problem is. Maybe that first branch returns False? Maybe Casting fails?

And… What does that trigger output in the timeline do? I’ve never seen it there before.

You’re welcome. These key conflicts are pain in the ■■■. You should set your inputs in project settings and use those instead of keys.