A teleport trigger component specialized for this game. It overrides TeleportBody to find a SkatePawn on the teleported GameObject and call its TeleportTo method so the pawn's rotation and velocity handling remains consistent; otherwise it falls back to the base TeleportVolume behavior.
using LegacyEntityPack;
using Skateboard.Player;
namespace Skateboard.Entities;
/// <summary>
/// Teleport volume that also teleports the skater. Inherits the generic
/// <see cref="TeleportVolume"/> and routes the move through this game's
/// <see cref="SkatePawn"/> so the controller's rotation/velocity stay consistent.
/// </summary>
[Title( "Teleport Volume (Skate)" )]
[Category( "Skateboard/Triggers" )]
[Icon( "auto_fix_normal" )]
public sealed class SkateTeleportVolume : TeleportVolume
{
protected override void TeleportBody( GameObject body, Transform destination, Vector3 offset )
{
var pawn = body.Components.Get<SkatePawn>( FindMode.EverythingInSelfAndAncestors );
if ( pawn.IsValid() )
{
var target = destination;
target.Position += offset;
pawn.TeleportTo( target, KeepVelocity );
return;
}
base.TeleportBody( body, destination, offset );
}
}