Referencing a target point in my UI Widget

Hello everyone,

What I want to achieve: I`m in a VR Environment and when the player turns the left hand a UI Widget Pops-Up next to the players´s wrist. In this UI I have several buttons that can be pressed - so far all of this works - now when the button is pressed the player should be teleported to the location (and with the rotation) of a target point object that I placed somewhere in my level.

The problem: I can`t put the target point into my blueprint from the UI Widget Creator (the graph) - if I create a variable (target point) and I try to drag and drop the target point from my World Outliner the tooltip says “Editing this value in a classdefault object is not allowed”

My workaround is to type in the desired coordinates by hand but that is quite time consuming and not very flexible…

Every tips is much appreciated,
thx
Jajujo

What you want to do is only possible when objects are placed in the same level. In case of your widget you need to do it diffrently.

One way, the most simple: Use GetAllActorsOfClass and search for your target point class. If you have multiple target points, you might give tags to your points to filter them.
Though if you need high performance, this is discuraged.

You could also add the target point to your Player or GameState or PlayerState or PlayerController class. On BeginPlay of the TargetPoint, register it to one of these objects. From the Widget get the registration object and from that the TargetPoint.

From your TargetPoint drag of and GetActorLocation (or GetWorldLocation in case of a component)

Hi Rumbleball,
sorry for the late reply… I didn’t have time for my project last week :slight_smile:

When I use the getallactorsofclass node I still can’t reference to my target points on the map :confused: They simply don’t appear in the dropdown…
So for clarification:

I have an VRPlayerPawn, in this pawn i have my camera and my player hands as child components.
These Hands (I am using the LeapMotion Controller to track my hands in real-time) have the Widget attached.
This widget needs to reference to a target point in the level…

Sorry but I am a noob when it comes to scripting :smiley:

Hello ! GetAllActorsOfClass will return all instances of a class that are spawned in the world.
If you created a BP named TargetPoint (I guess that’s what you did), you just need to pass the BP reference (the one in your content browser) to this node, and at runtime it will store all your spawned target points in an array. Then it’s up to you to find a way to get the correct one, maybe with an ID variable or whatever.

Also to connect your nodes you need to “GetActorLocation” and “GetActorRotation” from your TargetPoint Reference.

1 Like