public void TeleportHumanoid()
        {
            if (!active)
            {
                return;
            }

            HumanoidControl humanoid = transformToTeleport.GetComponent <HumanoidControl>();

            if (humanoid == null)
            {
                transformToTeleport.Teleport(focusPointObj.transform.position);
            }
            else
            {
                Vector3 interactionPointerPosition = humanoid.GetHumanoidPosition() - transformToTeleport.position;

                switch (transportType)
                {
                case TransportType.Teleport:
                    transformToTeleport.Teleport(focusPointObj.transform.position - interactionPointerPosition);
                    break;

                case TransportType.Dash:
                    StartCoroutine(TransformMovements.DashCoroutine(transformToTeleport, focusPointObj.transform.position - interactionPointerPosition));
                    break;

                default:
                    break;
                }
            }
        }
Example #2
0
        public static void MoveTo(this Transform transform, Vector3 position, MovementType movementType = MovementType.Teleport)
        {
            switch (movementType)
            {
            case MovementType.Teleport:
                TransformMovements.Teleport(transform, position);
                break;

            case MovementType.Dash:
                MonoBehaviour monoBehaviour = transform.GetComponent <MonoBehaviour>();
                if (monoBehaviour == null)
                {
                    Debug.LogError("Dash not possible. No MonoBehaviour found on " + transform);
                }
                else
                {
                    monoBehaviour.StartCoroutine(TransformMovements.DashCoroutine(transform, position));
                }
                break;

            default:
                break;
            }
        }
 public void Teleport(Vector3 targetPosition)
 {
     TransformMovements.Teleport(this.transform, targetPosition);
 }
 public void Teleport()
 {
     TransformMovements.Teleport(this.transform, this.transform.position + this.transform.forward * 2);
 }
 public void Dash(Vector3 targetPosition)
 {
     StartCoroutine(TransformMovements.DashCoroutine(transform, targetPosition));
 }