void BounceBack(Beyblade other, float collisionResult) { Vector3 collisionDir = (GetComponent <Rigidbody>().velocity - other.GetComponent <Rigidbody>().velocity).normalized; //TODO: FIX HARDCODED MINIMUM Vector3 bounceBack = m_mc.m_maxSpeed * Utilities.sigmoid(collisionResult, 4) * collisionDir; if (bounceBack.magnitude < 60) { bounceBack = 60 * collisionDir; } GetComponent <Rigidbody>().velocity = -1 * bounceBack; other.GetComponent <Rigidbody>().velocity = bounceBack; }
IEnumerator FreezeFrame3D(Beyblade p1, Beyblade p2, Vector3 bounceBack) { ResetLight(); p1.GetComponent <ClashEventModule>().enabled = false; p2.GetComponent <ClashEventModule>().enabled = false; //Unfreeze physics p1.GetComponentInChildren <MovementControls>().enabled = true; p1.GetComponentInChildren <TiltControls>().enabled = true; p2.GetComponentInChildren <MovementControls>().enabled = true; p2.GetComponentInChildren <TiltControls>().enabled = true; //TODO: Hard Coded Value p1.BounceBack(p2, bounceBack, 200); //UnFocus Camera m_cam.ResetCameras(); //Disable Shield p1.GetComponent <ShieldController>().enabled = false; p2.GetComponent <ShieldController>().enabled = false; yield return(new WaitForSeconds(m_delayTransition)); //Enable Pieces p1.EnableBeybladePieces(); p2.EnableBeybladePieces(); //Enable Controls p1.EnablePlayerInfluence(); p2.EnablePlayerInfluence(); //Reset Collision p1.ResetCollision(); p2.ResetCollision(); }
public void BounceBack(Beyblade other, Vector3 dir, float magnitude = 60) { dir = dir.normalized * magnitude; GetComponent <Rigidbody>().velocity = -1 * dir; other.GetComponent <Rigidbody>().velocity = dir; }
bool ClashEventDecision(Beyblade other, float collisionResult) { return((collisionResult >= m_ceventDamageThreshold || GetComponent <Rigidbody>().velocity.magnitude + other.GetComponent <Rigidbody>().velocity.magnitude >= m_ceventVelocityThreshold) && collisionResult > 0f); }
IEnumerator FreezeFrame2D(Beyblade attacker, Beyblade defender, int comboCount, float clashSpeed) { //Freeze physics attacker.GetComponentInChildren <MovementControls>().enabled = false; attacker.GetComponentInChildren <TiltControls>().enabled = false; defender.GetComponentInChildren <MovementControls>().enabled = false; defender.GetComponentInChildren <TiltControls>().enabled = false; Vector3 a_velo = attacker.GetComponentInChildren <Rigidbody>().velocity; Vector3 d_velo = defender.GetComponentInChildren <Rigidbody>().velocity; //Set Velocity to 0 attacker.GetComponentInChildren <Rigidbody>().velocity = Vector3.zero; defender.GetComponentInChildren <Rigidbody>().velocity = Vector3.zero; //Initialize m_cevent.SetPlayers(attacker.GetComponent <ClashEventModule>(), defender.GetComponent <ClashEventModule>()); attacker.GetComponent <ClashEventModule>().enabled = true; defender.GetComponent <ClashEventModule>().enabled = true; //Disable Pieces attacker.DisableBeybladePieces(); defender.DisableBeybladePieces(); //Focused Camera m_cam.FocusMyCam(attacker.gameObject); yield return(new WaitForSeconds(m_delayTransition / 2)); attacker.BounceBack(defender, a_velo - d_velo); yield return(new WaitForSeconds(m_delayTransition / 2)); //Set Velocity to 0 attacker.GetComponentInChildren <Rigidbody>().velocity = Vector3.zero; defender.GetComponentInChildren <Rigidbody>().velocity = Vector3.zero; //Unfreeze physics attacker.GetComponentInChildren <MovementControls>().enabled = true; attacker.GetComponentInChildren <TiltControls>().enabled = true; defender.GetComponentInChildren <MovementControls>().enabled = true; defender.GetComponentInChildren <TiltControls>().enabled = true; //Disable Controls attacker.DisablePlayerInfluence(); defender.DisablePlayerInfluence(); //Designate Combo Count m_cevent.SetMaxCombo(comboCount); //Enable Shield defender.GetComponent <ShieldController>().enabled = true; //Set the Clash Speed if (clashSpeed > 0f) { m_cevent.SetAttackDuration(clashSpeed); } //Start the event m_cevent.enabled = true; }