void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); }
public void Init(int ID, string button, Color color, Transform sound) { mat0 = transform.GetChild(0).GetComponent <Renderer>().materials[1]; mat1 = transform.GetChild(0).GetComponent <Renderer>().materials[0]; transform.GetChild(1).GetComponent <Renderer>().material = mat0; rb = GetComponent <Rigidbody>(); anim = GetComponent <Animator>(); //emit = ps.emission; anim.SetInteger("State", 0); shielded.SetActive(true); shield = true; name = "Player" + ID; this.ID = ID; input = button; forward = transform.position.x < 0; mat0.SetColor("_Color2", color); _audio = SoundtrackScript.instance; rb.velocity = new Vector3((forward ? vel : -vel) * multiplier, (gravException ? 5 : (GameManager.instance.customGravity.y < 0 ? 5 : -5)) * multiplier, 0); _audio.CreateSound(8); }
private void Start() { instance = this; }