Files
beyond/Assets/ThirdParty/FluXY/Samples/Scripts/OpacityFromVelocity.cs
2024-11-20 15:21:28 +01:00

25 lines
472 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Fluxy;
[RequireComponent(typeof(FluxyTarget))]
public class OpacityFromVelocity : MonoBehaviour
{
public AnimationCurve velocityToOpacity = new AnimationCurve();
FluxyTarget target;
void Awake()
{
target = GetComponent<FluxyTarget>();
}
void Update()
{
var c = target.color;
c.a = velocityToOpacity.Evaluate(target.velocity.magnitude);
target.color = c;
}
}