using UnityEngine; /// Disables a CharacterController around a transform write so it cannot snap the transform back. public static class CharacterTeleport { public static void Move(CharacterController cc, Transform t, Vector3 position) { bool reenable = cc && cc.enabled; if (cc) cc.enabled = false; t.position = position; if (cc) cc.enabled = reenable; } public static void Move(CharacterController cc, Transform t, Vector3 position, Quaternion rotation) { bool reenable = cc && cc.enabled; if (cc) cc.enabled = false; t.SetPositionAndRotation(position, rotation); if (cc) cc.enabled = reenable; } }