private void OnCollisionStay(Collision collision) { if (collision.gameObject.tag == "Player") { if (collision.gameObject.name == "Player1") { PlayerController_p1 pc = collision.gameObject.GetComponent <PlayerController_p1>(); if (pc.shieldActivated && canPerfectBlock) { Debug.Log("perfect block done"); } else { Debug.Log("normal block done"); } } } }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Player") { if (collision.gameObject.name == "Player1") { PlayerController_p1 pc = collision.gameObject.GetComponent <PlayerController_p1>(); if (pc != null && pc.shieldActivated) //&&perfect block timer between x and y) { pc.canMove = false; ContactPoint con = collision.contacts[0]; direction = Reflect(direction, rotator.returnCurrentDirection()); pc.goRed = false; doAcceleration = true; } else if (pc != null && !pc.shieldActivated && !pc.DashingBool) { pc.canMove = false; pc.goRed = true; startPerfectBlockTimer = true; holdDisc = true; if (canPerfectBlock) { //Debug.Log("perfect block done"); } else { // Debug.Log("normal block done"); } } else if (pc != null && pc.DashingBool) { pc.canMove = false; ContactPoint con = collision.contacts[0]; Vector3 newDirection = new Vector3(pc.l_Movement.x, 0, 0); if (newDirection.x == 0) { newDirection.x = 1; } newDirection.Normalize(); direction = Reflect(direction, newDirection); } } if (collision.gameObject.name == "Player2") { PlayerController_p2 pc2 = collision.gameObject.GetComponent <PlayerController_p2>(); if (pc2 != null && pc2.shieldActivated) { ContactPoint con = collision.contacts[0]; direction = Reflect(direction, rotator2.returnCurrentDirection()); pc2.goRed = false; doAcceleration = true; } else if (pc2 != null && !pc2.shieldActivated && !pc2.DashingBool) { pc2.goRed = true; pointScored(1); //score to player 1 } else if (pc2 != null && pc2.DashingBool) { pc2.canMove = false; ContactPoint con = collision.contacts[0]; Vector3 newDirection = new Vector3(pc2.l_Movement.x, 0, 0); if (newDirection.x == 0) { newDirection.x = -1; } newDirection.Normalize(); direction = Reflect(direction, newDirection); } } } if (collision.gameObject.tag == "Wall") { ContactPoint con = collision.contacts[0]; direction = Reflect(direction, con.normal); } if (collision.gameObject.tag == "Goal2") { pointScored(1); } if (collision.gameObject.tag == "Goal") { pointScored(2); } }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Player") { if (collision.gameObject.name == "Player1") { PlayerController_p1 pc = collision.gameObject.GetComponent <PlayerController_p1>(); if (pc != null && pc.shieldActivated) { ContactPoint con = collision.contacts[0]; direction = Reflect(direction, rotator.returnCurrentDirection()); pc.goRed = false; // doAcceleration=true; } else if (pc != null && !pc.shieldActivated) { pc.goRed = true; sumScore(2); pointScored = true; pointScoredForPlayerTwo = true; pointScoredForPlayerOne = false; } } if (collision.gameObject.name == "Player2") { PlayerController_p2 pc2 = collision.gameObject.GetComponent <PlayerController_p2>(); if (pc2 != null && pc2.canReturnDisc) { ContactPoint con = collision.contacts[0]; direction = Reflect(direction, rotator2.returnCurrentDirection()); pc2.goRed = false; //doAcceleration = true; } else if (pc2 != null && !pc2.canReturnDisc) { pc2.goRed = true; sumScore(1); pointScored = true; pointScoredForPlayerOne = true; pointScoredForPlayerTwo = false; //score to player 1 } } } if (collision.gameObject.tag == "Wall") { ContactPoint con = collision.contacts[0]; direction = Reflect(direction, con.normal); //doAcceleration = true; } if (collision.gameObject.tag == "Goal2") { Debug.Log("wall 2"); sumScore(1); pointScored = true; pointScoredForPlayerOne = true; pointScoredForPlayerTwo = false; } if (collision.gameObject.tag == "Goal") { Debug.Log("wall 1"); sumScore(2); pointScored = true; pointScoredForPlayerTwo = true; pointScoredForPlayerOne = false; } }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Player") { if (collision.gameObject.name == "Player1") { PlayerController_p1 pc = collision.gameObject.GetComponent <PlayerController_p1>(); if (pc != null && pc.shieldActivated) { pc.canMove = false; ContactPoint con = collision.contacts[0]; direction = Reflect(direction, rotator.returnCurrentDirection()); pc.goRed = false; doAcceleration = true; } else if (pc != null && !pc.shieldActivated && !pc.DashingBool) { pc.canMove = false; pc.goRed = true; pointScored(2); } else if (pc != null && pc.DashingBool) { pc.canMove = false; ContactPoint con = collision.contacts[0]; Vector3 newDirection = new Vector3(pc.l_Movement.x, 0, 0); if (newDirection.x == 0) { newDirection.x = 1; } newDirection.Normalize(); direction = Reflect(direction, newDirection); } } if (collision.gameObject.name == "IA") { IA pc2 = collision.gameObject.GetComponent <IA>(); if (pc2 != null && pc2.canReturnDisc) { ContactPoint con = collision.contacts[0]; direction = Reflect(direction, rotator.returnCurrentDirection()); pc2.goRed = false; doAcceleration = true; } else if (pc2 != null && !pc2.canReturnDisc) { pc2.goRed = true; pointScored(1); //score to player 1 } } } if (collision.gameObject.tag == "Wall") { ContactPoint con = collision.contacts[0]; direction = Reflect(direction, con.normal); } if (collision.gameObject.tag == "Goal2") { pointScored(1); } if (collision.gameObject.tag == "Goal") { pointScored(2); } }