SLEAPY_SMURF/Assets/JMO Assets/Cartoon FX Remaster/Demo Assets/CFXR_Demo_Translate.cs

42 lines
943 B
C#
Raw Normal View History

2023-04-30 11:23:57 +00:00
//--------------------------------------------------------------------------------------------------------------------------------
// Cartoon FX
// (c) 2012-2020 Jean Moreno
//--------------------------------------------------------------------------------------------------------------------------------
using UnityEngine;
namespace CartoonFX
{
public class CFXR_Demo_Translate : MonoBehaviour
{
public Vector3 direction = new Vector3(0,1,0);
public bool randomRotation;
bool initialized;
Vector3 initialPosition;
void Awake()
{
if (!initialized)
{
initialized = true;
initialPosition = this.transform.position;
}
}
void OnEnable()
{
this.transform.position = initialPosition;
if (randomRotation)
{
this.transform.eulerAngles = Vector3.Lerp(Vector3.zero, Vector3.up * 360, Random.value);
}
}
void Update()
{
this.transform.Translate(direction * Time.deltaTime);
}
}
}