GameVsJam/3d Prototyp/Assets/UMotionExamples/Miscellaneous/Scripts/ResetPosition.cs

26 lines
520 B
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ResetPosition : MonoBehaviour
{
public float distanceToReset = 5;
private Vector3 startPosition;
// Use this for initialization
void Start ()
{
startPosition = transform.position;
}
// Update is called once per frame
void Update ()
{
if (Vector3.Distance(startPosition, transform.position) >= distanceToReset)
{
transform.position = startPosition;
}
}
}