2024-07-12
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
1. Basic attributes
(1) Change the duration of emitted particles to 1s
(2) Uncheck Looping
(3) Modify the particle life time (Start Lifetime) to a random value between 0.1 and 0.2
(4) Change the particle initial speed (Start Speed) to 0
(5) Change the particle's Start Size to a random value between 0.7 and 1.
(6) Change the particle's initial rotation angle (Start Rotation) to a random value between 0 and 360
2. Emission
(1) Set the emission particle speed (Rate over Time) to 0 (i.e. no particles are emitted)
(2) Add a Burst, with a Time of 0 and a Count of 5
3. Emitter Shape
(1) Set the Shape to Circle
(2) Set the rotation angle (Rotation) in the x-axis direction to 900
(3) Set the radius to 0.12
(4) Set the Mode to Burst Spread
4. Particle Color (Color over Lifetime)
(1) Set the transparency to 255-0 (i.e., increasingly transparent)
5. Particle size (Size over Lifetime)
(1) Set the particle size to 0.6-1
6. Texture Sheet Animation
(1) Add particle sprite image
1. Edit the bullet script:
(1) Create a hit effect prefab
- public class Bullet : MonoBehaviour
- {
- // 创建命中特效预制体
- public GameObject hitEffectParticlePrefab;
- }
(2) Rewrite the iterator interface and delete the hit particle effects after a delay of 1s
- public class Bullet : MonoBehaviour
- {
- // 创建命中特效预制体
- public GameObject hitEffectParticlePrefab;
-
- // 在1s后删除粒子特效
- private async Task deleteEffectParticle(GameObject EffectParticle, float delay)
- {
- // 等待1s
- await Task.Delay(1000);
- // 删除粒子特效
- Destroy(EffectParticle);
- }
- }
(3) When hitting an enemy, a hit particle effect is created at the bullet's location and deleted after 1 second.
- public class Bullet : MonoBehaviour
- {
- // 创建命中特效预制体
- public GameObject hitEffectParticlePrefab;
-
- // 击中敌人
- private void OnCollisionEnter2D(Collision2D collision)
- {
- Enemy enemy = collision.gameObject.GetComponent<Enemy>();
- if(enemy != null) {
- enemy.changeHealthPoint(-25);
- GameObject hitEffectParticle = Instantiate(hitEffectParticlePrefab, transform.position, Quaternion.identity);
- deleteHitEffectParticle(hitEffectParticle, 1);
- }
- Destroy(gameObject);
- }
-
- // 在1s后删除粒子特效
- public static async Task deleteEffectParticle(GameObject EffectParticle, float delay)
- {
- // 等待1s
- await Task.Delay(1000);
- // 删除粒子特效
- Destroy(EffectParticle);
- }
- }
2. Add hit particle effects to the bullet prefab
3. The final effect is shown in the figure below:
This chapter is over. Thanks for reading!