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

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;
}
}