Skip to content

World coordinate NetworkTransform.Teleport that internally handles InLocalSpace #2856

@zachstronaut

Description

@zachstronaut

I'm using an extension method right now:

public static void TeleportInWorld( this NetworkTransform _ref, Vector3 _worldPosition, Quaternion _worldRotation )
{
    Debug.Assert(_ref.CanCommitToTransform);
    bool needsChange = _ref.InLocalSpace && _ref.transform.parent;
    var newPos = needsChange ? _ref.transform.parent.InverseTransformPoint(_worldPosition) : _worldPosition;
    var newRot = needsChange ? _ref.transform.parent.rotation.Inverted() * _worldRotation : _worldRotation;
    _ref.Teleport(newPos, newRot, _ref.transform.localScale);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:featureNew feature, request or improvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions