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.

28 lines
654 B

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class Float : MonoBehaviour
  5. {
  6. [SerializeField]
  7. private Vector3 m_direction;
  8. [SerializeField]
  9. private float m_speed;
  10. private Vector3 m_startPosition;
  11. private float m_randomOffset;
  12. // Start is called before the first frame update
  13. void Start()
  14. {
  15. m_startPosition = transform.position;
  16. m_randomOffset = Random.Range(0.0f, 1.0f);
  17. }
  18. // Update is called once per frame
  19. void Update()
  20. {
  21. transform.position = m_startPosition + Mathf.Sin(Time.time * m_speed + m_randomOffset) * m_direction;
  22. }
  23. }