21 lines
473 B
C#
21 lines
473 B
C#
using UnityEngine;
|
|
|
|
public class SinMovement : MonoBehaviour{
|
|
private float originalY;
|
|
|
|
public float speed;
|
|
public float scale;
|
|
|
|
public float offset;
|
|
|
|
void Start(){
|
|
originalY = transform.position.y;
|
|
offset += Random.Range(-1, 1);
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update(){
|
|
transform.position = transform.position.Flatten(null, originalY + Mathf.Sin((Time.time + offset) * speed) * scale, null);
|
|
}
|
|
}
|