Programming dynamic target for BP

I’m trying to code a teleportation pad for a game I’m working on, but I want to make it into a blueprint so non-programmer friends can help me make levels. I’ve seen that you can use the Teleport function in BP but it doesn’t allow me to dynamically set the target to an in editor asset.

The goal would be for them to drag and drop a teleporter pad into the level, then drag a target pad into the level and direct the teleporter to set it’s target to the second pad by name reference. I could just have them place a box where they want to tele to, then put its X,Y,Z into the target, but I want to keep it as user friendly as possible. Checked answer hub/Wiki and no dice. Any ideas?

You can create a variable in your teleporter pad blueprint that holds a value of type “target pad”. Set the variable to editable. When the blueprint user selects the teleporter pad, he can select an target pad in the editor.
The teleporter pad can then reference the target pad’s location. (Be sure to check if target pad is set and print an error otherwise)

Edit: I didn’t see this being in the C++ forum. See below for C++ answer :slight_smile:

Hey, in this case make an editor exposed pointer to the other teleporter. In the editor designers can then use the actor picking tool to select the target teleporter in the editor. Be sure to take into account an unassigned value (check for NULL). Try something like this in your teleporter C++ class:



UPROPERTY(EditInstanceOnly, Category = TeleporterPad)
AMyTeleporterClass * TargetPad;


Now if you drag a teleporter pad in the level, you’ll see the TargetPad property in the details panel. Next to it should be the picking tool that allows you to pick another teleporter from the level viewport. EditInstanceOnly since the target teleporter is level dependent so you can’t have a default value.

Edit: posted the BP version. Take your pick. :slight_smile: