enemy spawner
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
//--------------------------------------------------------------------------------------------------------------------------------
|
||||
// Cartoon FX
|
||||
// (c) 2012-2025 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user