Teleporting a character using a button in a widget to an object

Hello all
Tell me, please: when I click on the button in the widget, the character is instantly teleported to the object by coordinates. I tried to do it using the “Teleport” or “SetActorLocation” blocks, to which the “Gecharakhter” was connected (only in this way it moves to the object), but in this case, the control of movement on the map falls. As a result, moving with the mouse is not possible.

Tell me, please, how can I implement the teleport of the character, without losing control on the map.
I would be happy and grateful for any help.

Hey there @Gladkiiler! Welcome to the community!

Are you trying to just move the player character via button and it’s disabling the player’s input? Could we get a bit of insight into your BP?

Included is a simple setup for a quick and simple UI button to teleport to a specific object. You can also pass in that actor specifically by reference instead.

Thanks a lot

True, after adding this part to the code, control disappears when the left mouse button is pressed. That is, moving around the map, but at the same time, pressing the right mouse button, which is responsible for rotating around the map, works normally

Hmm, sounds like your click event it being consumed somewhere since other inputs are working. So let’s run a couple tests to see what could be eating it!

So first culprit: UI elements can eat left click events

If you’re trying multiclick/multitouch, the IsFocus bool on your UI elements can intercept left clicks.

Do you have any UI in front of the click events?

Do you have any inputs that are direct left clicks on anything?

May I see where you inputs are setup?

Since it’s On Tick I think the best move would be to first check after the gate what the hit location is printing. If the hit location is not valid at the time we can assume it’s blocked. If that print doesn’t fire, we can assume the input itself is being eaten.

Checked up an input - the print works. And so I checked the “Move to Hit Location” function itself, everything also works at the output, where the brunch is, everything works along the way true

Ahhhh excellent information! So if hit location is working, the actual Move command itself is failing. This is more indicative of a Navigation mesh issue. Is your navigation mesh covering the area in which you teleport? (You can hit P in viewport to view if it’s covering the area). Depending on the size of your world this can be alleviated in project settings for smaller setups, or you may have to use some open world design if your world is large enough. A quick test would be that if you teleport like 5 units away, does it still break movement?

Yes, the navigation mesh covers the entire area. The world is large enough. I moved 10 units in x and y and the teleport worked. And how can I make teleportation work over long distances?

So if it is indeed the nav mesh distance being the problem, for massive landscapes it’s recommended to use navigation invokers like this:

Disclaimer: One or more of these links are unaffiliated with Epic Games. Epic Games is not liable for anything that may occur outside of this Unreal Engine domain. Please exercise your best judgment when following links outside of the forums.

If that doesn’t work out (still congrats you set up a super useful tool for open world games), we’ll need to take the hit location and run some checks on where the path is failing.

1 Like