Browse Source

particles on magnet turn on and off

master
Joshua Reason 9 years ago
parent
commit
db9615b169
3 changed files with 8 additions and 1 deletions
  1. +8
    -1
      unity_Project/Assets/Scripts/MagnetLaser.cs
  2. BIN
      unity_Project/Assets/_Scenes/MainLevel.unity
  3. BIN
      unity_Project/ProjectSettings/ProjectSettings.asset

+ 8
- 1
unity_Project/Assets/Scripts/MagnetLaser.cs View File

@ -9,13 +9,14 @@ public class MagnetLaser : MonoBehaviour {
public int segments;
public float randomSize;
private magnetGun gun;
private ParticleSystem[] sparks;
// Use this for initialization
void Start () {
gun = player.GetComponent<magnetGun> ();
lr = GetComponent<LineRenderer> ();
sparks = gun.GetComponentsInChildren<ParticleSystem>();
}
@ -25,6 +26,10 @@ public class MagnetLaser : MonoBehaviour {
void Update () {
if (gun.GravityTarget != null) {
sparks[0].enableEmission = true;
sparks[1].enableEmission = true;
lr.enabled = true;
lr.SetVertexCount(segments+1);
lr.SetPosition(0, rodstart.transform.position);
@ -48,6 +53,8 @@ public class MagnetLaser : MonoBehaviour {
} else {
lr.enabled = false;
sparks[0].enableEmission = false;
sparks[1].enableEmission = false;
}

BIN
unity_Project/Assets/_Scenes/MainLevel.unity View File


BIN
unity_Project/ProjectSettings/ProjectSettings.asset View File


Loading…
Cancel
Save