Global Game Jam 2022
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
775 B

2 years ago
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class PlatformMover : MonoBehaviour
  5. {
  6. [SerializeField] private Transform m_StartPos;
  7. [SerializeField] private Transform m_EndPos;
  8. [SerializeField] private float m_Duration = 2f;
  9. // Start is called before the first frame update
  10. void Start()
  11. {
  12. }
  13. // Update is called once per frame
  14. void Update()
  15. {
  16. transform.position = Vector2.Lerp(m_StartPos.position, m_EndPos.position, Mathf.PingPong(Time.deltaTime * m_Duration, 1.0f));
  17. }
  18. #if UNITY_EDITOR
  19. private void OnDrawGizmos()
  20. {
  21. Gizmos.color = Color.green;
  22. Gizmos.DrawLine(m_StartPos.position, m_EndPos.position);
  23. }
  24. #endif
  25. }