void collision(float ground) { animator.SetInteger("state", 0 + TYPE); if (!is_in) { if (pos.y < ground + playerHeight / 2.0 || vel.y > 0) { //vel.x = -(float)((vel.x + sign(read_vel2.x)*5));//deflected vel.x = -(float)((vel.x - read_vel2.x)); //deflected sound.PlayBump(); } vel.y = -(float)(vel.y); if (pos.y > ground && !(vel.y < 0)) //since velocity just got inverted... checking that it WAS going down { if (pos.y > pos2.y) { if (!GameObject.Find(other_player_name).GetComponent <ActionScript>().defenseOn) { this.GetComponent <HealthScript>().TakeDamage(1); } else { GameObject.Find(other_player_name).GetComponent <ActionScript>().shieldHits++; GameObject.Find(other_player_name).GetComponent <Renderer>().material.SetColor("_Color", Color.blue); if (GameObject.Find(other_player_name).GetComponent <ActionScript>().shieldHits >= 3) { GameObject.Find(other_player_name).GetComponent <ActionScript>().shield.transform.localScale = new Vector3(0, 0, 0); GameObject.Find(other_player_name).GetComponent <ActionScript>().defenseOn = false; GameObject.Find(other_player_name).GetComponent <ActionScript>().shieldHits = 0; GameObject.Find(other_player_name).GetComponent <ActionScript>().defCooldown = 0; } } sound.PlayStomp(); } //float inside = sign(pos2.y - pos.y)*(1 - abs(pos2.y - pos.y)); //if(pos.y > pos2.y)//if(!(pos2.y > pos.y)) //this.transform.Translate(0f, -inside, 0f); //push back a little } } }