|
|
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
-
- public class PlatformMover : MonoBehaviour
- {
- [SerializeField] private Transform m_StartPos;
- [SerializeField] private Transform m_EndPos;
- [SerializeField] private float m_Duration = 2f;
-
- // Start is called before the first frame update
- void Start()
- {
-
- }
-
- // Update is called once per frame
- void Update()
- {
- transform.position = Vector2.Lerp(m_StartPos.position, m_EndPos.position, Mathf.PingPong(Time.deltaTime * m_Duration, 1.0f));
- }
-
- #if UNITY_EDITOR
- private void OnDrawGizmos()
- {
- Gizmos.color = Color.green;
- Gizmos.DrawLine(m_StartPos.position, m_EndPos.position);
- }
- #endif
- }
|