public override void Update(DefenderController_FSM player) { player.myRb.AddRelativeForce(Vector2.right * player.pushPower * Time.fixedDeltaTime); //call the actions based on the probs if (frameCounter == 0) { //this is for preventing the angular velocity problem player.myRb.isKinematic = false; float prob = GetNaiveActionProb(); /*if(prob <= 0.5f) * { * //Default Action * DuellRotate(player); * * }*/ if (prob <= 0.7f) { //Push Action // 1.) disable the joint player.joint.enabled = false; //2.) Push the other rb away player.otherRb.AddRelativeForce(Vector2.left * 2); //3.) change to the PassBlock state player.TransitionToState(player.idle_state); } else { //Knock Over Action player.TransitionToState(player.down_state); } frameCounter = 50; } else { frameCounter--; } }
public override void Update(DefenderController_FSM player) { if (player.joint.enabled == false) { player.myRb.angularVelocity = 0.0f; player.otherRb.angularVelocity = 0.0f; } player.joint.enabled = true; player.TransitionToState(player.push_State); }
public override void Update(DefenderController_FSM player) { //move first object float angle = Vector2.SignedAngle(player.otherObject.position - player.transform.position, new Vector2(1.0f, 0.0f)); player.myRb.MoveRotation(-angle); if (frameCounter == 0) { //for the cross product we need to compare the vectors from the QB to the Receiver //to the Vector from the QB to the Defender Vector2 defenderQbVector = player.myRb.transform.position - player.QBtransform.position; Vector2 receiverQbVector = player.otherObject.transform.position - player.QBtransform.position; if (IsLeft(defenderQbVector, receiverQbVector)) { player.myRb.AddRelativeForce(Vector2.up * player.speed); //Debug.Log("Is left"); } else { player.myRb.AddRelativeForce(Vector2.up * -player.speed); //Debug.Log("Is right"); } frameCounter = 20; } else { frameCounter--; } if (player.colliders.Length > 0) { //player.TransitionToState(player.snap_State); player.TransitionToState(player.push_State); } }
private IEnumerator FinishResetDelay(DefenderController_FSM player) { yield return(new WaitForSeconds(0.5f)); player.TransitionToState(player.passBlock_State); }
private IEnumerator BeIdle_Cor(DefenderController_FSM player) { yield return(new WaitForSeconds(1f)); player.TransitionToState(player.passBlock_State); }