1
0
Fork 0

change player particle emmision to scale by speed

This commit is contained in:
Jan 2018-04-23 19:14:18 +02:00
parent e81f7808d7
commit 35a3c21c91

View file

@ -3,6 +3,8 @@ using UnityEngine;
public class Player : Mob {
Rigidbody2D body;
[SerializeField]
private GameObject bulletPrefab;
[SerializeField]
@ -26,6 +28,7 @@ public class Player : Mob {
g.SetPrefab(bulletPrefab);
g.SetSpawn(bulletSpawn);
ggun = g;
body = GetComponent<Rigidbody2D>();
SetAttack(s);
}
@ -47,6 +50,10 @@ public class Player : Mob {
nextAttackTime = Time.timeSinceLevelLoad + attack.GetCooldownTime();
}
}
float velocity = body.velocity.magnitude;
ParticleSystem.EmissionModule emission = GetComponentInChildren<ParticleSystem>().emission;
emission.rateOverTime = velocity * (velocity / 2) * 20 + 20;
Debug.Log(emission.rateOverTime.constant);
}