Efficient way to teleport my character via a timer?

I attempted to do this in the traditional way (player.transform.position), but the Opsive UFPS controller character is different from a standard character, so I'm having troubles. I'm aware that the Opsive kit comes with a teleporter pad function, but I'm having issues creating a "teleport by timer" script similar to it.

Essentially, if a timer reaches a certain number (say, 500), I want my player to automatically teleport to a set location. Instead of walking into a collider of some sort, I just want it to sorta happen automatically.

I see that this is more complicated than I thought it'd be, but I'm willing to learn how to do it properly even if its convoluted.
 
You should set the position on the locomotion: https://opsive.com/support/documentation/ultimate-character-controller/character/

The Teleporter in the demo scene uses this method. You can use the scheduler or coroutine to call it after a specified amount of time.
Would it be best to copy the teleport code, and instead of the part that says

[RequireComponent(typeof(BoxCollider))]

I remove that and use the coroutine/scheduler stuff instead? I'm thinking about using a bool to say "teleNow" and have it warp my character regardless of their position.

I'm just a bit confused with this type of coding; most of my projects have been very simple in the past.
 
All you'd really need to do is use a Coroutine for the timer, at the end of which you'd call SetPositionAndRotation on the character as in the example Teleporter script. The rest of the stuff in that script is not really relevant, apart from maybe preventing teleport if the drive/ride abilities are active.
 
Top