41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
using UnityEngine;
|
|
|
|
public class IntroFloatingLayer : MonoBehaviour
|
|
{
|
|
[Header("Floating Movement")]
|
|
public float moveAmountY = 0.05f;
|
|
public float moveAmountX = 0.02f;
|
|
public float speed = 1.0f;
|
|
|
|
[Header("Scale Pulse")]
|
|
public bool useScalePulse = false;
|
|
public float scaleAmount = 0.02f;
|
|
public float scaleSpeed = 1.0f;
|
|
|
|
private Vector3 startPosition;
|
|
private Vector3 startScale;
|
|
private float randomOffset;
|
|
|
|
private void Awake()
|
|
{
|
|
startPosition = transform.localPosition;
|
|
startScale = transform.localScale;
|
|
randomOffset = Random.Range(0f, 100f);
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
float t = Time.time + randomOffset;
|
|
|
|
float offsetY = Mathf.Sin(t * speed) * moveAmountY;
|
|
float offsetX = Mathf.Cos(t * speed * 0.7f) * moveAmountX;
|
|
|
|
transform.localPosition = startPosition + new Vector3(offsetX, offsetY, 0f);
|
|
|
|
if (useScalePulse)
|
|
{
|
|
float scaleOffset = Mathf.Sin(t * scaleSpeed) * scaleAmount;
|
|
transform.localScale = startScale * (1f + scaleOffset);
|
|
}
|
|
}
|
|
} |