#Teleport Script

1 messages · Page 1 of 1 (latest)

round cove
#

I understand. So I have copied both EPF_Const.c and EPF_Component.c to my project and now I am running the following teleport script. It teleports the player and the Tardis collider, just like before, but the mesh remains behind 😦

Am I missing something?

#
{
//------------------------------------------------------------------------------------------------
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
{
    vector playerPosition = "5130.698 16 4016.885".ToVector();
    vector tardisPosition = "5135.343 14.508 4028.185".ToVector();

    // Teleport the player
    Teleport(pUserEntity, playerPosition);

    // Teleport the TARDIS
    Teleport(pOwnerEntity, tardisPosition);
        
    Print("Player coordinates: " + pUserEntity.GetOrigin());
    Print("TARDIS coordinates: " + pOwnerEntity.GetOrigin());
}

//------------------------------------------------------------------------------------------------
override bool GetActionNameScript(out string outName)
{
    outName = "Teleport";
    return true;
}

static void Teleport(notnull IEntity entity, vector position, float yaw = "nan".ToFloat())
{
    vector transform[4];

    if (!EPF_Const.IsNan(yaw))
    {
        Math3D.AnglesToMatrix(Vector(yaw, 0, 0), transform);
    }
    else
    {
        entity.GetWorldTransform(transform);
    }

    transform[3] = position;
    SCR_TerrainHelper.OrientToTerrain(transform);

    ForceTransformEx(entity, transform);
}

static void ForceTransformEx(notnull IEntity entity, vector transform[4])
{
    vector previousOrigin = entity.GetOrigin();

    BaseGameEntity baseGameEntity = BaseGameEntity.Cast(entity);
    if (baseGameEntity && !BaseVehicle.Cast(baseGameEntity))
    {
        baseGameEntity.Teleport(transform);
    }
    else
    {
        entity.SetWorldTransform(transform);
    }

    Physics physics = entity.GetPhysics();
    if (physics)
    {
        physics.SetVelocity(vector.Zero);
        physics.SetAngularVelocity(vector.Zero);
    }

    RplComponent replication = EPF_Component<RplComponent>.Find(entity);
    if (replication)
        replication.ForceNodeMovement(previousOrigin);

    if (!ChimeraCharacter.Cast(entity))
        entity.Update();
}
};```
round cove
#

@tame ivy Any idea if I am missing something there? blobdoggoshruggoogly

tame ivy
#

the mesh should not stay behind because of the transformex update call in the end normally. so i am unsure what exactly is going on in your case. i lack the time to debug this for you, so you need to try around yourself and see if all calls are made as they should

round cove
#

Ok! Will do 💪

round cove
#

It's funny... I tested it again... I didn't change naything and it just works