This commit is contained in:
2023-04-08 01:23:11 -04:00
parent 02b827102c
commit 1ba73e3f13
49 changed files with 40483 additions and 36 deletions

View File

@ -0,0 +1,74 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.VFX;
[ExecuteAlways]
public class SwarmAnimator : MonoBehaviour
{
[SerializeField]
private VisualEffect vfx;
private Vector3 currentPosition;
private Vector3 previousPosition;
[SerializeField]
private Rigidbody rb;
[SerializeField]
private string parameterName = "DeltaVector";
[SerializeField]
private Vector3 avoidancePosDefault;
[SerializeField]
private float explodeDuration = 1.0f;
private float dur = 0f;
private bool isExploding = false;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
previousPosition = currentPosition;
currentPosition = transform.position;
Vector3 velocity = (currentPosition - previousPosition) ;
vfx.SetVector3("DeltaVector", velocity);
if (Input.GetKeyDown(KeyCode.Space))
{
Explode();
}
if (isExploding)
{
if(dur> explodeDuration)
{
StopExplode();
}
dur += Time.deltaTime;
}
}
void Explode()
{
vfx.SetVector3("Avoid", transform.position);
this.isExploding = true;
dur = 0;
//Wait a sec then stop.
}
void StopExplode()
{
vfx.SetVector3("Avoid", avoidancePosDefault);
this.isExploding = false;
vfx.Stop();
}
private void FixedUpdate()
{
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 735497967e6cfdf4090b8092757c54a8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: