WinterJamSnowman/Assets/Scripts/LemonGenericLib/Visual Effects/SineWaveHover.cs

29 lines
780 B
C#
Raw Normal View History

2023-01-24 13:51:46 +00:00
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);
}
}
}