How to create a teleport Button Widget

Hello Devs. I have created a teleport Blueprint that allows me to click on a sphere, and it teleports the player. This is what my blueprint currently looks like:

My question is, I have a button in my main UI that I need to reference to this same blueprint. So when a user clicks on the button, I need this button to do the exact same thing. How do I go about doing this?

  1. Lets assume the logic you have is in BP_Teleporter as I don’t know the object’s its name.

  2. You create a public, instance editableBP_Teleporer variable in your widget exposed on spawn.

  3. When you create your widget, pass the BP_Teleporter to it and when you click the button call the corresponding function on your BP_Teleporter variable. (which was already set on creation)

Note: Don’t make gameplay logic in the the widget. Make the teleportation in the level, on the character or on another object and pass that to the widget.

Is it possible to show me how that would look in blueprint?

Sure.

BP_Teleporter:


Now this logic might be directly in the character to avoid the indirection.

BP_Character:


Here you should find a way to provide the teleporter to the character. I’ve set it directly when placing he character in the level.

WBP_TeleportButton


Don’t forget to set it exposed on spawn to be available in the BP_Character