Teleporting player on trigger (PhysX)

The problem seems easy enough to solve but nothing I tried worked. I have my player (PhysX rigid body) and my trigger area (PhysX collider with Trigger ticked). The trigger area works because of test message prints into the console log btw.

What I need is to make this trigger move the player to coordinates XYZ or to another entity. So far I tried: Set World Translation, Set Local Translation, Try Relative Move, Set Base Position, Set Parent Relative.

Nothing worked and I’m getting pretty frustrated :smiley: Any help would be much appreciated

Set World Translation should work. Is this scriptcanvas graph on the trigger entity or the player? If it’s on the trigger the player entity must be the source of Set World Translation. If the graph is on the player entity the source can be self. If you attach your graph as a zip file, I’d take a look.

SetWorldTranslation

The script is placed in the trigger entity, not the player. I tried doing it the way you suggested but it did not work for some reason :confused: I’m also attaching the zip you requested :slight_smile:

Pictures.zip (2.2 MB)

Hi @MagicD3VIL, the reason the entity does not teleport is because it has an active rigid body so physics is controlling the position. There should be two options you can try:

Set the RigidBody to Kinematic momentarily

  1. Set the RigidBody component to be kinematic
  2. Set the player position with Set World Translation
  3. Set the RigidBody component back to not being kinematic - you might have to wait a frame to do this.

Re-activate the Player entity

  1. Have you Trigger Entity set the player position like you are doing
  2. Deactivate the player game entity and then immediately re-activate it (this triggers some internal logic that disconnects the rigidbody from the Physics system and re-registers it in the new location.

This is the lua script for my trigger area teleporter that used method #2

2 Likes

If you haven’t seen them theres a 5 part series of video tutorials called “Lmberyard Basics of Motion” that cover a lot of how todo things like this:

https://www.youtube.com/watch?v=sf4EUSZt4IM I think covers what you are trying to do.

Full series is here: https://www.youtube.com/playlist?list=PLjd5NhkT3LsiQiidX7P0JG4xr9Ed_fCB2

1 Like

Greetings everyone!

@petrocket, I ended up using the first method and it worked flawlessly after a few tweaks. Initially, there were few visual glitches like the player blinking fast while being teleported but I fixed that. Also when the player entered the trigger while not holding any of WASD 70% of the time the player got slingshotted out of the map by physics (idk how but it looked funny). So thanks a lot for your help!

@Pip, the video was very instructive but it was not what I needed but still thanks for the help.

I’m also attaching the 2 script canvases if someone would be interested in taking a look. The triggertest2 is the zone that will teleport you and the triggertest3 is the zone you are being teleported to. scriptcanvas.zip (20.9 KB)

Thanks again, guys.