From 35a3c21c91384e7708f59c6cff98fe136de44521 Mon Sep 17 00:00:00 2001 From: Jan Date: Mon, 23 Apr 2018 19:14:18 +0200 Subject: [PATCH] change player particle emmision to scale by speed --- Assets/Scripts/Entities/Player.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Assets/Scripts/Entities/Player.cs b/Assets/Scripts/Entities/Player.cs index 8d0816b..a6a48b7 100644 --- a/Assets/Scripts/Entities/Player.cs +++ b/Assets/Scripts/Entities/Player.cs @@ -2,6 +2,8 @@ using UnityEngine; public class Player : Mob { + + Rigidbody2D body; [SerializeField] private GameObject bulletPrefab; @@ -26,6 +28,7 @@ public class Player : Mob { g.SetPrefab(bulletPrefab); g.SetSpawn(bulletSpawn); ggun = g; + body = GetComponent(); SetAttack(s); } @@ -47,6 +50,10 @@ public class Player : Mob { nextAttackTime = Time.timeSinceLevelLoad + attack.GetCooldownTime(); } } + float velocity = body.velocity.magnitude; + ParticleSystem.EmissionModule emission = GetComponentInChildren().emission; + emission.rateOverTime = velocity * (velocity / 2) * 20 + 20; + Debug.Log(emission.rateOverTime.constant); }