-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPosToPos.cs
36 lines (30 loc) · 918 Bytes
/
PosToPos.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PosToPos : MonoBehaviour
{
[Header("Target Position")]
[SerializeField] private Transform _GotoPosition = null;
[Header("Settings")]
[SerializeField] private float _Speed = 1;
[SerializeField] private bool _Lerp = false;
[SerializeField] private bool _OnStart = false;
private bool _Activated;
private void Start()
{
if (_OnStart)
StartMoving();
}
void Update()
{
if (_Activated)
if (_Lerp)
transform.position = Vector3.Lerp(transform.position, _GotoPosition.position, _Speed * Time.deltaTime);
else
transform.position = Vector3.MoveTowards(transform.position, _GotoPosition.position, _Speed * Time.deltaTime);
}
public void StartMoving()
{
_Activated = true;
}
}