Download

Referencing wrong instance

Hello,

I am trying to make steath game and i am stuck at the “door hacking” part. The setup is simple.

You walk up to a door, box trigger goes off and checks if you have already unlocked/hacked the door. if so then it opens and closes when you leave the trigger. if not the it opens up a widget with a few buttons and you have to chose the right button to hack it. This is all part of the door blueprint (see attachment). if you get the right button it fires off a custom event and the door gets unlock/hacked and it will open en close for you.

It seems to go wrong at the widget blueprint. if you press the right button it try to cast to the door blueprint en fire off the event. and this works fine if you have only a single door. but when i duplicate the door/make another instance of it. it stops working. it seems that its casting to the orginal door/ the first instance of the door.

I cant seem to find a way to make it cast to the right instance of the door. can you guys help out a starter?

With kind regards,
Tromp

You are only casting to the door with index 0 of all doors, which is the first one you’ve made. You will have to use another way to get the door reference than “Get all actors of class” since you would also need the index of the door for that to work.

ah ic, any suggestions on how to get the reference off the door instance that called create widget? can i pass it along when i call create widget?

You could add an actor variable to the widget which you cast a reference from self to as the door creates the widget.

I am a bit confussed on when and what of you suggestion.

From what i gather you propose that i make a actor variable in the widget. and that i somehow fill that variable in the Door BP as i create the widget?

Yes, when the widget is created by the door, it (the door) would at the same time cast to the widget a reference of itself to the actor reference. I hope this is better formulated.