// Use this for initialization void Start() { player = GameObject.FindWithTag("Player").GetComponent <character_scr> (); if (lifeTime <= 0) { lifeTime = 1.0f; } if (player.isFacingLeft == true) { GetComponent <Rigidbody2D> ().velocity = new Vector2(speed, 0); Destroy(gameObject, lifeTime); } else { GetComponent <Rigidbody2D> ().velocity = new Vector2(speed, 0); Vector3 scaleFactor = transform.localScale; //invert the x scale so that your character changes the direction he's facing scaleFactor.x *= -1; //update the scalefactor so that it will always change the direction properly transform.localScale = scaleFactor; Destroy(gameObject, lifeTime); } }
// Use this for initialization void Start() { player = GameObject.FindWithTag("Player").GetComponent <character_scr> (); if (!healthBar) { Debug.LogError("No health bar found"); } }
// Use this for initialization void Start() { player = GameObject.FindWithTag("Player").GetComponent <character_scr> (); if (lifeTime <= 0) { lifeTime = 0.25f; Debug.LogWarning("Changing lifeTime to: " + lifeTime); } Destroy(gameObject, lifeTime); } //end void start()
// Use this for initialization void Start() { if (instance) { DestroyImmediate(gameObject); // destroys the new one that was just created } else { instance = this; DontDestroyOnLoad(this); } character = GetComponent <character_scr> (); //assign a starting score score = 0; knifeCount = 10; SoundManager.instance.SoundCaller("MusicTitle"); }