add particles
add vfx
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DefaultNamespace
|
||||
{
|
||||
[RequireComponent(typeof(ParticleSystem))]
|
||||
public class OneShot : MonoBehaviour
|
||||
{
|
||||
private ParticleSystem _particleSystem;
|
||||
private ParticleSystem.MainModule _main;
|
||||
private ParticleSystem.ColorOverLifetimeModule _colorOverLifetime;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_particleSystem = GetComponent<ParticleSystem>();
|
||||
_main = _particleSystem.main;
|
||||
_main.loop = false;
|
||||
_main.playOnAwake = false;
|
||||
|
||||
_colorOverLifetime = _particleSystem.colorOverLifetime;
|
||||
// _colorOverLifetime.
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetButtonDown("Fire1"))
|
||||
{
|
||||
_particleSystem.Play(); // play particle system with settings
|
||||
// _particleSystem.Emit(100); // emit 100 particles at once
|
||||
}
|
||||
|
||||
ParticleSystem.Particle[] particles = new ParticleSystem.Particle[_particleSystem.main.maxParticles];
|
||||
int usedParticles = _particleSystem.GetParticles(particles);
|
||||
for (int i = 0; i < usedParticles; i++)
|
||||
{
|
||||
particles[i].position += Vector3.up * 0.01f;
|
||||
}
|
||||
_particleSystem.SetParticles(particles);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e9b49ca71a945189648e61e989c005f
|
||||
timeCreated: 1732818962
|
||||
Reference in New Issue
Block a user