using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Float : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private Vector3 m_direction;
|
|
|
|
[SerializeField]
|
|
private float m_speed;
|
|
|
|
private Vector3 m_startPosition;
|
|
private float m_randomOffset;
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
m_startPosition = transform.position;
|
|
m_randomOffset = Random.Range(0.0f, 1.0f);
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
transform.position = m_startPosition + Mathf.Sin(Time.time * m_speed + m_randomOffset) * m_direction;
|
|
}
|
|
}
|