How can i set a dynamic object reference?

Hi, i am working on a game, where i want to set different clocks. I can change the time on one clock, but as soon as i put in more clocks in, the reference is set to one specific clock. So i just access on clock from every other clock.
I tried to get the hit info from the line trace, and set the reference to the hit object but still i get the same problem. Can anyone help me please?


This is my clock. With the two buttons on the left, i can spin the hours counter clockwise and clockwise. Same for the two buttons on the right for the minutes. The buttons are in a widget class W_SetClock.


This is the graph of the widget. It fires four events, when i press the buttons, where the corresponding rotate function is called, on the actor class. The Problem is, the actor class is always the same. Lets say i got clock 1, 2, 3, 4. The actor class is always clock 1. I tried to fix that by the event at the top called “set clock reference”, where i set the clock.


This is where “set clock reference” gets called. You can see it in the top right corner. Its the blueprint of my player. I use the line trace to get the hit actor. When i hit the clock, i call the functions “interact” and “set clock reference”. The input parameter for set clock reference is my hit actor, which should be the clock, that interacted with. But still, when i interact with clock 2, nothing changes, but clock 1 changes. I don’t get any errors, it just doesn’t work how i want it. What am I doing wrong here?

When you get that actor from the linetrace, that is your dynamic ref.

Just pass it to the widget.

But i’m already doing that, am i not? Look at the last picture in the top right corner. I pass the hit actor to the clock of set clock reference. That’s why i’m wondering, why it doesn’t work.

Ok I got it. I just have to plug the hit object right into the target in the W_SetClock called function. Weirdly, I didn’t get an error before I closed Unreal. When I opened it again, i got a compiler error, which I fixed. Now everything works. Sometimes you just gotta turn it off and on again :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.