void OnCollisionEnter2D(Collision2D hitInfo) { // enemy enemy = hitInfo.gameObject.GetComponent<enemy>(); // if(enemy != null) // { // enemy.TakeDamage(damage); // } cube_attributes player = hitInfo.gameObject.GetComponent <cube_attributes>(); if (player != null) { player.TakeDamage(damage); } // barrierdetails barrier = hitInfo.gameObject.GetComponent<barrierdetails>(); // if(barrier != null) // { // barrier.TakeDamage(damage); // } // //Debug.Log(hitInfo.gameObject.name); if (hitInfo.gameObject.tag != "bullets") // destroy if collide with anything/dont need? { // impact = Instantiate(impact, transform.position, Quaternion.identity); *create effect upon collide* GameObject ParticleObject = Instantiate(Particle, transform.position, Quaternion.identity); ParticleSystem Effect = ParticleObject.GetComponent <ParticleSystem>(); var main = Effect.main; main.startColor = Sprite.color; Destroy(gameObject); // Destroy(impact, 0.5f); } }
void Start() { player = GameObject.Find("Cubeman"); CubeAttributes = player.GetComponent <cube_attributes>(); Color_Selection = player.GetComponent <color_selection>(); SetColorDefault(); }
void Start() { if (SceneManager.GetActiveScene().buildIndex == 2) { Player = GameObject.Find("Cubeman"); Cube_Attributes = Player.GetComponent <cube_attributes>(); LoadColor(); } }
//bullet spawning ------------------------------- void OnCollisionEnter2D(Collision2D hitInfo) { cube_attributes player = hitInfo.gameObject.GetComponent <cube_attributes>(); if (player != null) { player.TakeDamage(30); } }
void OnCollisionEnter2D(Collision2D hitInfo) { cube_attributes player = hitInfo.gameObject.GetComponent <cube_attributes>(); if (player != null) { player.HealHP(HealValue); Destroy(gameObject); } }