29 lines
780 B
C#
29 lines
780 B
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
namespace Lemon.GenericLib.VFX
|
|||
|
{
|
|||
|
//this only works for sprite objects
|
|||
|
public class SineWaveHover : MonoBehaviour
|
|||
|
{
|
|||
|
[SerializeField] float effectSpeed = 1;
|
|||
|
[SerializeField] float effectMultiplier = 1;
|
|||
|
[SerializeField] public float effectOffset = 1;
|
|||
|
|
|||
|
float yPos;
|
|||
|
Vector3 originalPos;
|
|||
|
|
|||
|
private void Start()
|
|||
|
{
|
|||
|
originalPos = transform.localPosition;
|
|||
|
}
|
|||
|
|
|||
|
// Update is called once per frame
|
|||
|
void Update()
|
|||
|
{
|
|||
|
yPos = Mathf.Sin((Time.time + effectOffset) * effectSpeed) * effectMultiplier;
|
|||
|
transform.localPosition = originalPos + new Vector3(0, yPos, 0);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|