public void ApplyForces(MoveInfo move) { //if (myControlsScript.debugger != null) myControlsScript.debugger.text = ""; //if (myControlsScript.debugger != null) myControlsScript.debugger.text = "IsGrounded = " + IsGrounded() + "\n"; //if (myControlsScript.debugger != null) myControlsScript.debugger.text += "verticalForce = " + verticalForce + "\n"; //if (myControlsScript.debugger != null) myControlsScript.debugger.text += "verticalTotalForce = " + verticalTotalForce + "\n"; //if (myControlsScript.debugger != null) myControlsScript.debugger.text += "normalizedJumpArc = " + myControlsScript.normalizedJumpArc + "\n"; //if (myControlsScript.debugger != null) myControlsScript.debugger.text += "isTakingOff = " + isTakingOff + "\n"; //if (myControlsScript.debugger != null) myControlsScript.debugger.text += "myControlsScript.currentState = " + myControlsScript.currentState + "\n"; if (freeze) { return; } myControlsScript.normalizedJumpArc = 1 - ((verticalForce + verticalTotalForce) / (verticalTotalForce * 2)); float appliedFriction = (moveDirection != 0 || myControlsScript.myInfo.physics.highMovingFriction) ? UFE.config.selectedStage.groundFriction : myControlsScript.myInfo.physics.friction; if (move != null && move.ignoreFriction) { appliedFriction = 0; } if (myControlsScript.activePullIn != null) { transform.position = Vector3.Lerp(transform.position, myControlsScript.activePullIn.position, Time.fixedDeltaTime * myControlsScript.activePullIn.speed); if (myControlsScript.activePullIn.forceStand && !IsGrounded()) { ForceGrounded(); } if (Vector3.Distance(myControlsScript.activePullIn.position, transform.position) <= myControlsScript.activePullIn.targetDistance || myControlsScript.currentSubState != SubStates.Stunned) { myControlsScript.activePullIn = null; } //if (transform.position.z != 0) transform.Translate(new Vector3(0, 0, -transform.position.z)); } else { if (!IsGrounded()) { appliedFriction = 0; if (verticalForce == 0) { verticalForce = -.1f; } } if (horizontalForce != 0 && !isTakingOff) { if (horizontalForce > 0) { horizontalForce -= appliedFriction * Time.fixedDeltaTime; horizontalForce = Mathf.Max(0, horizontalForce); } else if (horizontalForce < 0) { horizontalForce += appliedFriction * Time.fixedDeltaTime; horizontalForce = Mathf.Min(0, horizontalForce); } transform.Translate(horizontalForce * Time.fixedDeltaTime, 0, 0); } if (move == null || (move != null && !move.ignoreGravity)) { if ((verticalForce < 0 && !IsGrounded()) || verticalForce > 0) { verticalForce -= appliedGravity * Time.fixedDeltaTime; transform.Translate(moveDirection * myControlsScript.myInfo.physics.jumpDistance * Time.fixedDeltaTime, verticalForce * Time.fixedDeltaTime, 0); } else if (verticalForce < 0 && IsGrounded()) { currentAirJumps = 0; verticalForce = 0; } } } /*if (myControlsScript.debugger != null) { * myControlsScript.debugger.text = "isBouncing = " + isBouncing + "\n"; * myControlsScript.debugger.text += "controlsScript.stunTime = " + controlsScript.stunTime + "\n"; * myControlsScript.debugger.text += "Animations:\n"; * foreach(AnimationState animState in character.animation){ * if (myMoveSetScript.IsAnimationPlaying(animState.name)){ * myControlsScript.debugger.text += "<color=#003300>"+ animState.name +"</color>\n"; * myControlsScript.debugger.text += "<color=#003300>"+ animState.speed +"</color>\n"; * } * } * }*/ /*if (UFE.normalizedCam) { * Vector3 cameraLeftBounds = Camera.main.ViewportToWorldPoint(new Vector3(0,0,-Camera.main.transform.position.z - 10)); * Vector3 cameraRightBounds = Camera.main.ViewportToWorldPoint(new Vector3(1,0,-Camera.main.transform.position.z - 10)); * * transform.position = new Vector3( * Mathf.Clamp(transform.position.x,cameraLeftBounds.x,cameraRightBounds.x), * transform.position.y, * transform.position.z); * }*/ float minDist = myControlsScript.opponent.transform.position.x - UFE.config.cameraOptions.maxDistance; float maxDist = myControlsScript.opponent.transform.position.x + UFE.config.cameraOptions.maxDistance; transform.position = new Vector3(Mathf.Clamp(transform.position.x, minDist, maxDist), transform.position.y, transform.position.z); transform.position = new Vector3( Mathf.Clamp(transform.position.x, UFE.config.selectedStage.leftBoundary, UFE.config.selectedStage.rightBoundary), transform.position.y, transform.position.z); if (myControlsScript.currentState == PossibleStates.Down) { return; } if (IsGrounded() && myControlsScript.currentState != PossibleStates.Down) { if (verticalTotalForce != 0) { if (bounceTimes < UFE.config.bounceOptions.maximumBounces && myControlsScript.currentSubState == SubStates.Stunned && UFE.config.bounceOptions.bounceForce != Sizes.None && verticalForce <= -UFE.config.bounceOptions.minimumBounceForce) { if (!UFE.config.bounceOptions.bounceHitBoxes) { myHitBoxesScript.HideHitBoxes(true); } if (UFE.config.bounceOptions.bounceForce == Sizes.Small) { AddForce(new Vector2(0, -verticalForce / 2.4f), 1); } else if (UFE.config.bounceOptions.bounceForce == Sizes.Medium) { AddForce(new Vector2(0, -verticalForce / 1.8f), 1); } else if (UFE.config.bounceOptions.bounceForce == Sizes.High) { AddForce(new Vector2(0, -verticalForce / 1.2f), 1); } bounceTimes++; if (!isBouncing) { if (myMoveSetScript.basicMoves.bounce.clip1 == null) { Debug.LogError("Bounce animation not found! Make sure you have it set on Character -> Basic Moves -> Bounce"); } myControlsScript.stunTime += airTime + UFE.config.knockDownOptions.air.knockedOutTime; myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.bounce); if (UFE.config.bounceOptions.bouncePrefab != null) { GameObject pTemp = (GameObject)Instantiate(UFE.config.bounceOptions.bouncePrefab); pTemp.transform.parent = transform; pTemp.transform.localPosition = Vector3.zero; Destroy(pTemp, UFE.config.bounceOptions.bounceKillTime); } if (UFE.config.bounceOptions.shakeCamOnBounce) { myControlsScript.shakeDensity = UFE.config.bounceOptions.shakeDensity; } UFE.PlaySound(UFE.config.bounceOptions.bounceSound); isBouncing = true; } return; } verticalTotalForce = 0; airTime = 0; myMoveSetScript.totalAirMoves = 0; BasicMoveInfo airAnimation = null; isBouncing = false; bounceTimes = 0; float animationSpeed = 0; float delayTime = 0; if (myControlsScript.currentMove != null && myControlsScript.currentMove.hitAnimationOverride) { return; } if (myControlsScript.currentSubState == SubStates.Stunned) { myControlsScript.stunTime = UFE.config.knockDownOptions.air.knockedOutTime + UFE.config.knockDownOptions.air.standUpTime; if (myMoveSetScript.basicMoves.fallDown.clip1 == null) { Debug.LogError("Fall Down From Air Hit animation not found! Make sure you have it set on Character -> Basic Moves -> Fall Down From Air Hit"); } airAnimation = myMoveSetScript.basicMoves.fallDown; myControlsScript.currentState = PossibleStates.Down; if (!UFE.config.knockDownOptions.air.standUpHitBoxes) { myHitBoxesScript.HideHitBoxes(true); } } else if (myControlsScript.currentState != PossibleStates.Stand) { if (myMoveSetScript.basicMoves.landing.clip1 != null && ((myControlsScript.currentMove != null && myControlsScript.currentMove.cancelMoveWheLanding) || myControlsScript.currentMove == null)) { airAnimation = myMoveSetScript.basicMoves.landing; moveDirection = 0; isLanding = true; myControlsScript.KillCurrentMove(); delayTime = (float)myControlsScript.myInfo.physics.landingDelay / UFE.config.fps; UFE.DelaySynchronizedAction(ResetLanding, delayTime); if (airAnimation.autoSpeed) { animationSpeed = myMoveSetScript.GetAnimationLengh(airAnimation.name) / delayTime; } } if (myControlsScript.currentState != PossibleStates.Crouch) { myControlsScript.currentState = PossibleStates.Stand; } } if (airAnimation != null && !myMoveSetScript.IsAnimationPlaying(airAnimation.name)) { myMoveSetScript.PlayBasicMove(airAnimation); if (animationSpeed != 0) { myMoveSetScript.SetAnimationSpeed(airAnimation.name, animationSpeed); } } } if (myControlsScript.currentSubState != SubStates.Stunned && !myControlsScript.isBlocking && !myControlsScript.blockStunned && move == null && !isTakingOff && !isLanding && myControlsScript.currentState == PossibleStates.Stand) { if (moveDirection > 0 && myControlsScript.mirror == -1 || moveDirection < 0 && myControlsScript.mirror == 1) { if (myMoveSetScript.basicMoves.moveForward.clip1 == null) { Debug.LogError("Move Forward animation not found! Make sure you have it set on Character -> Basic Moves -> Move Forward"); } if (!myMoveSetScript.IsAnimationPlaying(myMoveSetScript.basicMoves.moveForward.name)) { myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.moveForward); } } else if (moveDirection > 0 && myControlsScript.mirror == 1 || moveDirection < 0 && myControlsScript.mirror == -1) { if (myMoveSetScript.basicMoves.moveBack.clip1 == null) { Debug.LogError("Move Back animation not found! Make sure you have it set on Character -> Basic Moves -> Move Back"); } if (!myMoveSetScript.IsAnimationPlaying(myMoveSetScript.basicMoves.moveBack.name)) { myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.moveBack); } } } } else if ((verticalForce > 0 || !IsGrounded())) { if (move != null && myControlsScript.currentState == PossibleStates.Stand) { myControlsScript.currentState = PossibleStates.StraightJump; } if (move == null && verticalForce / verticalTotalForce > 0 && verticalForce / verticalTotalForce <= 1) { if (isBouncing) { return; } if (moveDirection == 0) { myControlsScript.currentState = PossibleStates.StraightJump; } else { if (moveDirection > 0 && myControlsScript.mirror == -1 || moveDirection < 0 && myControlsScript.mirror == 1) { myControlsScript.currentState = PossibleStates.ForwardJump; } if (moveDirection > 0 && myControlsScript.mirror == 1 || moveDirection < 0 && myControlsScript.mirror == -1) { myControlsScript.currentState = PossibleStates.BackJump; } } BasicMoveInfo airAnimation; if (myControlsScript.currentSubState == SubStates.Stunned) { if (myMoveSetScript.basicMoves.getHitKnockBack.clip1 != null && Mathf.Abs(horizontalForce) > UFE.config.comboOptions.knockBackMinForce && UFE.config.comboOptions.knockBackMinForce > 0) { airAnimation = myMoveSetScript.basicMoves.getHitKnockBack; } else { if (myMoveSetScript.basicMoves.getHitAir.clip1 == null) { Debug.LogError("Get Hit Air animation not found! Make sure you have it set on Character -> Basic Moves -> Get Hit Air"); } airAnimation = myMoveSetScript.basicMoves.getHitAir; } } else { if (myMoveSetScript.basicMoves.jumpForward.clip1 != null && myControlsScript.currentState == PossibleStates.ForwardJump) { airAnimation = myMoveSetScript.basicMoves.jumpForward; } else if (myMoveSetScript.basicMoves.jumpBack.clip1 != null && myControlsScript.currentState == PossibleStates.BackJump) { airAnimation = myMoveSetScript.basicMoves.jumpBack; } else { if (myMoveSetScript.basicMoves.jumpStraight.clip1 == null) { Debug.LogError("Jump animation not found! Make sure you have it set on Character -> Basic Moves -> Jump Straight"); } airAnimation = myMoveSetScript.basicMoves.jumpStraight; } } if (!myMoveSetScript.IsAnimationPlaying(airAnimation.name)) { myMoveSetScript.PlayBasicMove(airAnimation); if (airAnimation.autoSpeed) { myMoveSetScript.SetAnimationNormalizedSpeed(airAnimation.name, (myMoveSetScript.GetAnimationLengh(airAnimation.name) / (airTime * 2))); } //if (airAnimation.autoSpeed || myControlsScript.currentSubState == SubStates.Stunned) { //myMoveSetScript.SetAnimationNormalizedSpeed(airAnimation.name, (myMoveSetScript.GetAnimationLengh(airAnimation.name) / airTime)); } } else if (move == null && verticalForce / verticalTotalForce <= 0) { BasicMoveInfo airAnimation; if (isBouncing) { if (myMoveSetScript.basicMoves.fallingFromBounce.clip1 == null) { Debug.LogError("Falling From Bounce animation not found! Make sure you have it set on Character -> Basic Moves -> Falling From Bounce"); } airAnimation = myMoveSetScript.basicMoves.fallingFromBounce; if (myMoveSetScript.basicMoves.fallingFromBounce.invincible) { myHitBoxesScript.HideHitBoxes(true); } } else { if (myControlsScript.currentSubState == SubStates.Stunned) { if (myMoveSetScript.basicMoves.getHitKnockBack.clip1 != null && Mathf.Abs(horizontalForce) > UFE.config.comboOptions.knockBackMinForce && UFE.config.comboOptions.knockBackMinForce > 0) { airAnimation = myMoveSetScript.basicMoves.getHitKnockBack; } else { if (myMoveSetScript.basicMoves.getHitAir.clip1 == null) { Debug.LogError("Get Hit Air animation not found! Make sure you have it set on Character -> Basic Moves -> Get Hit Air"); } airAnimation = myMoveSetScript.basicMoves.getHitAir; } } else { if (myMoveSetScript.basicMoves.fallForward.clip1 != null && myControlsScript.currentState == PossibleStates.ForwardJump) { airAnimation = myMoveSetScript.basicMoves.fallForward; } else if (myMoveSetScript.basicMoves.fallBack.clip1 != null && myControlsScript.currentState == PossibleStates.BackJump) { airAnimation = myMoveSetScript.basicMoves.fallBack; } else { if (myMoveSetScript.basicMoves.fallStraight.clip1 == null) { Debug.LogError("Fall animation not found! Make sure you have it set on Character -> Basic Moves -> Fall Straight"); } airAnimation = myMoveSetScript.basicMoves.fallStraight; } } } if (!myMoveSetScript.IsAnimationPlaying(airAnimation.name)) { myMoveSetScript.PlayBasicMove(airAnimation); if (airAnimation.autoSpeed) { myMoveSetScript.SetAnimationNormalizedSpeed(airAnimation.name, (myMoveSetScript.GetAnimationLengh(airAnimation.name) / (airTime * 2))); } } } } if (horizontalForce == 0 && verticalForce == 0) { moveDirection = 0; } }
public void applyForces(MoveInfo move) { //if (myControlsScript.debugger != null) myControlsScript.debugger.text = "isBouncing = " + isBouncing + "\n"; if (freeze) { return; } float appliedFriction = (moveDirection != 0 || myControlsScript.myInfo.physics.highMovingFriction) ? 100 : myControlsScript.myInfo.physics.friction; if (!isGrounded()) { appliedFriction = 0; if (verticalForce == 0) { verticalForce = -.1f; } } if (horizontalForce != 0) { if (horizontalForce > 0) { horizontalForce -= appliedFriction * Time.deltaTime; horizontalForce = Mathf.Max(0, horizontalForce); } else if (horizontalForce < 0) { horizontalForce += appliedFriction * Time.deltaTime; horizontalForce = Mathf.Min(0, horizontalForce); } transform.Translate(horizontalForce * Time.deltaTime, 0, 0); } if (move == null || (move != null && !move.ignoreGravity)) { if ((verticalForce < 0 && !isGrounded()) || verticalForce > 0) { verticalForce -= appliedGravity * Time.deltaTime; transform.Translate(moveDirection * myControlsScript.myInfo.physics.jumpDistance * Time.deltaTime, verticalForce * Time.deltaTime, 0); } else if (verticalForce < 0 && isGrounded()) { currentAirJumps = 0; verticalForce = 0; } } /*if (myControlsScript.debugger != null) { * myControlsScript.debugger.text = "isBouncing = " + isBouncing + "\n"; * myControlsScript.debugger.text += "controlsScript.stunTime = " + controlsScript.stunTime + "\n"; * myControlsScript.debugger.text += "Animations:\n"; * foreach(AnimationState animState in character.animation){ * if (character.animation.IsPlaying(animState.name)){ * myControlsScript.debugger.text += "<color=#003300>"+ animState.name +"</color>\n"; * myControlsScript.debugger.text += "<color=#003300>"+ animState.speed +"</color>\n"; * } * } * }*/ if (isGrounded()) { if (verticalTotalForce != 0) { if (bounceTimes < UFE.config.bounceOptions.maximumBounces && myControlsScript.stunned && UFE.config.bounceOptions.bounceForce != Sizes.None && verticalForce <= -UFE.config.bounceOptions.minimumBounceForce) { if (!UFE.config.bounceOptions.bounceHitBoxes) { myHitBoxesScript.hideHitBoxes(); } if (UFE.config.bounceOptions.bounceForce == Sizes.Small) { addForce(new Vector2(0, -verticalForce / 2.4f), 1); } else if (UFE.config.bounceOptions.bounceForce == Sizes.Medium) { addForce(new Vector2(0, -verticalForce / 1.8f), 1); } else if (UFE.config.bounceOptions.bounceForce == Sizes.High) { addForce(new Vector2(0, -verticalForce / 1.2f), 1); } bounceTimes++; if (!isBouncing) { myControlsScript.stunTime += airTime + UFE.config.knockDownOptions.knockedOutTime; myMoveSetScript.playBasicMove(myMoveSetScript.basicMoves.bounce); if (UFE.config.bounceOptions.bouncePrefab != null) { GameObject pTemp = (GameObject)Instantiate(UFE.config.bounceOptions.bouncePrefab); pTemp.transform.parent = transform; pTemp.transform.localPosition = Vector3.zero; Destroy(pTemp, 3); } isBouncing = true; } return; } verticalTotalForce = 0; airTime = 0; myMoveSetScript.totalAirMoves = 0; BasicMoveInfo airAnimation = null; if (myControlsScript.stunned) { myControlsScript.stunTime = UFE.config.knockDownOptions.knockedOutTime + UFE.config.knockDownOptions.getUpTime; airAnimation = myMoveSetScript.basicMoves.fallDown; myControlsScript.currentState = PossibleStates.Down; if (!UFE.config.knockDownOptions.knockedOutHitBoxes) { myHitBoxesScript.hideHitBoxes(); } } else { if ((myControlsScript.currentMove != null && myControlsScript.currentMove.cancelMoveWheLanding) || myControlsScript.currentMove == null) { airAnimation = myMoveSetScript.basicMoves.landing; myControlsScript.KillCurrentMove(); } myControlsScript.currentState = PossibleStates.Stand; } isBouncing = false; bounceTimes = 0; if (airAnimation != null && !character.GetComponent <Animation>().IsPlaying(airAnimation.name)) { myMoveSetScript.playBasicMove(airAnimation); } } if (!myControlsScript.stunned && move == null) { if (moveDirection < 0 && myControlsScript.mirror == -1 || moveDirection > 0 && myControlsScript.mirror == 1) { myMoveSetScript.playBasicMove(myMoveSetScript.basicMoves.moveForward); } if (moveDirection < 0 && myControlsScript.mirror == 1 || moveDirection > 0 && myControlsScript.mirror == -1) { myMoveSetScript.playBasicMove(myMoveSetScript.basicMoves.moveBack); } } } else if (verticalForce > 0 || !isGrounded()) { if (move != null && myControlsScript.currentState == PossibleStates.Stand) { myControlsScript.currentState = PossibleStates.StraightJump; } if (move == null && verticalForce / verticalTotalForce > 0 && verticalForce / verticalTotalForce <= 1) { if (isBouncing) { return; } BasicMoveInfo airAnimation = myControlsScript.stunned? myMoveSetScript.basicMoves.getHitAir : myMoveSetScript.basicMoves.jumping; if (moveDirection == 0) { myControlsScript.currentState = PossibleStates.StraightJump; } else { if (moveDirection < 0 && myControlsScript.mirror == -1 || moveDirection > 0 && myControlsScript.mirror == 1) { myControlsScript.currentState = PossibleStates.ForwardJump; } if (moveDirection < 0 && myControlsScript.mirror == 1 || moveDirection > 0 && myControlsScript.mirror == -1) { myControlsScript.currentState = PossibleStates.BackJump; } } if (!character.GetComponent <Animation>().IsPlaying(airAnimation.name)) { //character.animation[airAnimation].speed = character.animation[airAnimation].length * (appliedGravity/verticalTotalForce); character.GetComponent <Animation>()[airAnimation.name].speed = character.GetComponent <Animation>()[airAnimation.name].length / airTime; myMoveSetScript.playBasicMove(airAnimation); } } else if (move == null && verticalForce / verticalTotalForce <= 0) { BasicMoveInfo airAnimation; if (isBouncing) { airAnimation = myMoveSetScript.basicMoves.fallingFromBounce; } else { airAnimation = myControlsScript.stunned? myMoveSetScript.basicMoves.getHitAir : myMoveSetScript.basicMoves.falling; } if (!character.GetComponent <Animation>().IsPlaying(airAnimation.name)) { //character.animation[airAnimation].speed = character.animation[airAnimation].length * (appliedGravity/verticalTotalForce); //character.animation.CrossFade(airAnimation, GlobalScript.getCurrentMoveSet(myControlsScript.myInfo).interpolationSpeed); character.GetComponent <Animation>()[airAnimation.name].speed = character.GetComponent <Animation>()[airAnimation.name].length / airTime; myMoveSetScript.playBasicMove(airAnimation); } } } if (horizontalForce == 0 && verticalForce == 0) { moveDirection = 0; } if (UFE.normalizedCam) { Vector3 cameraLeftBounds = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, -Camera.main.transform.position.z - 10)); Vector3 cameraRightBounds = Camera.main.ViewportToWorldPoint(new Vector3(1, 0, -Camera.main.transform.position.z - 10)); transform.position = new Vector3( Mathf.Clamp(transform.position.x, cameraLeftBounds.x, cameraRightBounds.x), transform.position.y, transform.position.z); } transform.position = new Vector3( Mathf.Clamp(transform.position.x, UFE.config.selectedStage.leftBoundary, UFE.config.selectedStage.rightBoundary), transform.position.y, transform.position.z); }
public void ApplyForces(MoveInfo move) { if (freeze) { return; } controlScript.normalizedJumpArc = (Fix64)1 - ((verticalForce + verticalTotalForce) / (verticalTotalForce * 2)); Fix64 appliedFriction = (moveDirection != 0 || controlScript.myInfo.physics.highMovingFriction) ? UFE.config.selectedStage._groundFriction : controlScript.myInfo.physics._friction; if (move != null && move.ignoreFriction) { appliedFriction = 0; } if (controlScript.activePullIn != null) { worldTransform.position = FPVector.Lerp(worldTransform.position, controlScript.activePullIn.position, UFE.fixedDeltaTime * controlScript.activePullIn.speed); if (controlScript.activePullIn.forceStand && !IsGrounded()) { ForceGrounded(); } if (FPVector.Distance(controlScript.activePullIn.position, worldTransform.position) <= controlScript.activePullIn._targetDistance || controlScript.currentSubState != SubStates.Stunned) { controlScript.activePullIn = null; } } else { if (!IsGrounded()) { appliedFriction = 0; if (verticalForce == 0) { verticalForce = -.1; } } if (horizontalForce != 0 && !isTakingOff) { if (horizontalForce > 0) { horizontalForce -= appliedFriction * UFE.fixedDeltaTime; horizontalForce = FPMath.Max(0, horizontalForce); } else if (horizontalForce < 0) { horizontalForce += appliedFriction * UFE.fixedDeltaTime; horizontalForce = FPMath.Min(0, horizontalForce); } Fix64 leftCameraBounds = opWorldTransform.position.x - (UFE.config.cameraOptions._maxDistance / 2); Fix64 rightCameraBounds = opWorldTransform.position.x + (UFE.config.cameraOptions._maxDistance / 2); bool bouncingOnCamera = false; if (controlScript.currentHit != null && controlScript.currentHit.bounceOnCameraEdge && (worldTransform.position.x <= leftCameraBounds || worldTransform.position.x >= rightCameraBounds)) { bouncingOnCamera = true; } if (wallBounceTimes < UFE.config.wallBounceOptions._maximumBounces && controlScript.currentSubState == SubStates.Stunned && controlScript.currentState != PossibleStates.Down && UFE.config.wallBounceOptions.bounceForce != Sizes.None && FPMath.Abs(horizontalForce) >= UFE.config.wallBounceOptions._minimumBounceForce && (worldTransform.position.x <= UFE.config.selectedStage._leftBoundary || worldTransform.position.x >= UFE.config.selectedStage._rightBoundary || bouncingOnCamera) && controlScript.currentHit != null && controlScript.currentHit.wallBounce && !isWallBouncing) { if (controlScript.currentHit.overrideForcesOnWallBounce) { if (controlScript.currentHit.resetWallBounceHorizontalPush) { horizontalForce = 0; } if (controlScript.currentHit.resetWallBounceVerticalPush) { verticalForce = 0; } Fix64 addedH = -controlScript.currentHit._wallBouncePushForce.x; Fix64 addedV = controlScript.currentHit._wallBouncePushForce.y; AddForce(new FPVector(addedH, addedV, 0), controlScript.mirror); } else { if (UFE.config.wallBounceOptions.bounceForce == Sizes.Small) { horizontalForce /= -1.4; } else if (UFE.config.wallBounceOptions.bounceForce == Sizes.Medium) { horizontalForce /= -1.2; } else if (UFE.config.wallBounceOptions.bounceForce == Sizes.High) { horizontalForce *= -1; } } wallBounceTimes++; if (verticalForce > 0 || !IsGrounded()) { if (moveSetScript.basicMoves.airWallBounce.animMap[0].clip != null) { controlScript.currentHitAnimation = moveSetScript.basicMoves.airWallBounce.name; } } else { if (controlScript.currentHit.knockOutOnWallBounce) { moveSetScript.PlayBasicMove(moveSetScript.basicMoves.standingWallBounceKnockdown); controlScript.currentHitAnimation = moveSetScript.basicMoves.standingWallBounceKnockdown.name; } else { moveSetScript.PlayBasicMove(moveSetScript.basicMoves.standingWallBounce); controlScript.currentHitAnimation = moveSetScript.basicMoves.standingWallBounce.name; } } if (UFE.config.wallBounceOptions.bouncePrefab != null) { GameObject pTemp = UFE.SpawnGameObject(UFE.config.wallBounceOptions.bouncePrefab, transform.position, Quaternion.identity, Mathf.RoundToInt(UFE.config.wallBounceOptions.bounceKillTime * UFE.config.fps)); pTemp.transform.rotation = UFE.config.wallBounceOptions.bouncePrefab.transform.rotation; if (UFE.config.wallBounceOptions.sticky) { pTemp.transform.parent = transform; } //pTemp.transform.localPosition = Vector3.zero; } if (UFE.config.wallBounceOptions.shakeCamOnBounce) { controlScript.shakeCameraDensity = UFE.config.wallBounceOptions._shakeDensity; } UFE.PlaySound(UFE.config.wallBounceOptions.bounceSound); isWallBouncing = true; } worldTransform.Translate((horizontalForce * UFE.fixedDeltaTime), 0, 0); } if (move == null || (move != null && !move.ignoreGravity)) { if ((verticalForce < 0 && !IsGrounded()) || verticalForce > 0) { verticalForce -= appliedGravity * UFE.fixedDeltaTime; worldTransform.Translate((moveDirection * UFE.fixedDeltaTime) * controlScript.myInfo.physics._jumpDistance, (verticalForce * UFE.fixedDeltaTime), 0); } else if (verticalForce < 0 && IsGrounded() && controlScript.currentSubState != SubStates.Stunned) { verticalForce = 0; } } } Fix64 minDist = opWorldTransform.position.x - UFE.config.cameraOptions._maxDistance; Fix64 maxDist = opWorldTransform.position.x + UFE.config.cameraOptions._maxDistance; worldTransform.position = new FPVector(FPMath.Clamp(worldTransform.position.x, minDist, maxDist), worldTransform.position.y, worldTransform.position.z); worldTransform.position = new FPVector( FPMath.Clamp(worldTransform.position.x, UFE.config.selectedStage._leftBoundary, UFE.config.selectedStage._rightBoundary), FPMath.Max(worldTransform.position.y, UFE.config.selectedStage._groundHeight), worldTransform.position.z); if (controlScript.currentState == PossibleStates.Down) { return; } if (IsGrounded() && controlScript.currentState != PossibleStates.Down) { if (verticalTotalForce != 0) { if (groundBounceTimes < UFE.config.groundBounceOptions._maximumBounces && controlScript.currentSubState == SubStates.Stunned && UFE.config.groundBounceOptions.bounceForce != Sizes.None && verticalForce <= -UFE.config.groundBounceOptions._minimumBounceForce && controlScript.currentHit.groundBounce) { if (controlScript.currentHit.overrideForcesOnGroundBounce) { if (controlScript.currentHit.resetGroundBounceHorizontalPush) { horizontalForce = 0; } if (controlScript.currentHit.resetGroundBounceVerticalPush) { verticalForce = 0; } Fix64 addedH = controlScript.currentHit._groundBouncePushForce.x; Fix64 addedV = controlScript.currentHit._groundBouncePushForce.y; AddForce(new FPVector(addedH, addedV, 0), controlScript.mirror); } else { if (UFE.config.groundBounceOptions.bounceForce == Sizes.Small) { AddForce(new FPVector(0, (-verticalForce / 2.4), 0), 1); } else if (UFE.config.groundBounceOptions.bounceForce == Sizes.Medium) { AddForce(new FPVector(0, (-verticalForce / 1.8), 0), 1); } else if (UFE.config.groundBounceOptions.bounceForce == Sizes.High) { AddForce(new FPVector(0, (-verticalForce / 1.2), 0), 1); } } groundBounceTimes++; if (!isGroundBouncing) { controlScript.stunTime += airTime + UFE.config.knockDownOptions.air._knockedOutTime; if (moveSetScript.basicMoves.groundBounce.animMap[0].clip != null) { controlScript.currentHitAnimation = moveSetScript.basicMoves.groundBounce.name; moveSetScript.PlayBasicMove(moveSetScript.basicMoves.groundBounce); } if (UFE.config.groundBounceOptions.bouncePrefab != null) { GameObject pTemp = UFE.SpawnGameObject(UFE.config.groundBounceOptions.bouncePrefab, transform.position, Quaternion.identity, Mathf.RoundToInt(UFE.config.groundBounceOptions.bounceKillTime * UFE.config.fps)); pTemp.transform.rotation = UFE.config.groundBounceOptions.bouncePrefab.transform.rotation; if (UFE.config.groundBounceOptions.sticky) { pTemp.transform.parent = transform; } //pTemp.transform.localPosition = Vector3.zero; } if (UFE.config.groundBounceOptions.shakeCamOnBounce) { controlScript.shakeCameraDensity = UFE.config.groundBounceOptions._shakeDensity; } UFE.PlaySound(UFE.config.groundBounceOptions.bounceSound); isGroundBouncing = true; } return; } verticalTotalForce = 0; airTime = 0; moveSetScript.totalAirMoves = 0; currentAirJumps = 0; BasicMoveInfo airAnimation = null; string downAnimation = ""; isGroundBouncing = false; groundBounceTimes = 0; Fix64 animationSpeed = 0; Fix64 delayTime = 0; if (controlScript.currentMove != null && controlScript.currentMove.hitAnimationOverride) { return; } if (controlScript.currentSubState == SubStates.Stunned) { if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.airRecovery.name)) { controlScript.stunTime = 0; controlScript.currentState = PossibleStates.Stand; } else { controlScript.stunTime = UFE.config.knockDownOptions.air._knockedOutTime + UFE.config.knockDownOptions.air._standUpTime; // Hit Clips if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.getHitKnockBack.name) && moveSetScript.basicMoves.getHitKnockBack.animMap[1].clip != null) { airAnimation = moveSetScript.basicMoves.getHitKnockBack; downAnimation = moveSetScript.GetAnimationString(airAnimation, 2); } else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.getHitHighKnockdown.name) && moveSetScript.basicMoves.getHitHighKnockdown.animMap[1].clip != null) { airAnimation = moveSetScript.basicMoves.getHitHighKnockdown; downAnimation = moveSetScript.GetAnimationString(airAnimation, 2); controlScript.stunTime = UFE.config.knockDownOptions.high._knockedOutTime + UFE.config.knockDownOptions.high._standUpTime; } else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.getHitMidKnockdown.name) && moveSetScript.basicMoves.getHitMidKnockdown.animMap[1].clip != null) { airAnimation = moveSetScript.basicMoves.getHitMidKnockdown; downAnimation = moveSetScript.GetAnimationString(airAnimation, 2); controlScript.stunTime = UFE.config.knockDownOptions.highLow._knockedOutTime + UFE.config.knockDownOptions.highLow._standUpTime; } else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.getHitSweep.name) && moveSetScript.basicMoves.getHitSweep.animMap[1].clip != null) { airAnimation = moveSetScript.basicMoves.getHitSweep; downAnimation = moveSetScript.GetAnimationString(airAnimation, 2); controlScript.stunTime = UFE.config.knockDownOptions.sweep._knockedOutTime + UFE.config.knockDownOptions.sweep._standUpTime; } else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.getHitCrumple.name) && moveSetScript.basicMoves.getHitCrumple.animMap[1].clip != null) { airAnimation = moveSetScript.basicMoves.getHitCrumple; downAnimation = moveSetScript.GetAnimationString(airAnimation, 2); // Stage Clips } else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.standingWallBounceKnockdown.name) && moveSetScript.basicMoves.standingWallBounceKnockdown.animMap[1].clip != null) { airAnimation = moveSetScript.basicMoves.standingWallBounceKnockdown; downAnimation = moveSetScript.GetAnimationString(airAnimation, 2); controlScript.stunTime = UFE.config.knockDownOptions.wallbounce._knockedOutTime + UFE.config.knockDownOptions.wallbounce._standUpTime; } else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.airWallBounce.name) && moveSetScript.basicMoves.airWallBounce.animMap[1].clip != null) { airAnimation = moveSetScript.basicMoves.airWallBounce; downAnimation = moveSetScript.GetAnimationString(airAnimation, 2); controlScript.stunTime = UFE.config.knockDownOptions.wallbounce._knockedOutTime + UFE.config.knockDownOptions.wallbounce._standUpTime; // Fall Clips } else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.fallingFromAirHit.name) && moveSetScript.basicMoves.fallingFromAirHit.animMap[1].clip != null) { airAnimation = moveSetScript.basicMoves.fallingFromAirHit; downAnimation = moveSetScript.GetAnimationString(airAnimation, 2); } else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.fallingFromGroundBounce.name) && moveSetScript.basicMoves.fallingFromGroundBounce.animMap[1].clip != null) { airAnimation = moveSetScript.basicMoves.fallingFromGroundBounce; downAnimation = moveSetScript.GetAnimationString(airAnimation, 2); } else { if (moveSetScript.basicMoves.fallDown.animMap[0].clip == null) { Debug.LogError("Fall Down From Air Hit animation not found! Make sure you have it set on Character -> Basic Moves -> Fall Down From Air Hit"); } airAnimation = moveSetScript.basicMoves.fallDown; downAnimation = moveSetScript.GetAnimationString(airAnimation, 1); } controlScript.currentState = PossibleStates.Down; } } else if (controlScript.currentState != PossibleStates.Stand) { if (moveSetScript.basicMoves.landing.animMap[0].clip != null && (controlScript.currentMove == null || (controlScript.currentMove != null && controlScript.currentMove.cancelMoveWheLanding))) { controlScript.isAirRecovering = false; airAnimation = moveSetScript.basicMoves.landing; moveDirection = 0; isLanding = true; controlScript.KillCurrentMove(); delayTime = (Fix64)controlScript.myInfo.physics.landingDelay / (Fix64)UFE.config.fps; UFE.DelaySynchronizedAction(ResetLanding, delayTime); if (airAnimation.autoSpeed) { animationSpeed = moveSetScript.GetAnimationLength(airAnimation.name) / delayTime; } } if (controlScript.currentState != PossibleStates.Crouch) { controlScript.currentState = PossibleStates.Stand; } } if (airAnimation != null) { if (downAnimation != "") { moveSetScript.PlayBasicMove(airAnimation, downAnimation); } else { moveSetScript.PlayBasicMove(airAnimation); } if (animationSpeed != 0) { moveSetScript.SetAnimationSpeed(airAnimation.name, animationSpeed); } } } if (controlScript.currentSubState != SubStates.Stunned && !controlScript.isBlocking && !controlScript.blockStunned && move == null && !isTakingOff && !isLanding && controlScript.currentState == PossibleStates.Stand) { if (moveDirection > 0 && controlScript.mirror == -1 || moveDirection < 0 && controlScript.mirror == 1) { if (moveSetScript.basicMoves.moveForward.animMap[0].clip == null) { Debug.LogError("Move Forward animation not found! Make sure you have it set on Character -> Basic Moves -> Move Forward"); } if (!moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.moveForward.name)) { moveSetScript.PlayBasicMove(moveSetScript.basicMoves.moveForward); } } else if (moveDirection > 0 && controlScript.mirror == 1 || moveDirection < 0 && controlScript.mirror == -1) { if (moveSetScript.basicMoves.moveBack.animMap[0].clip == null) { Debug.LogError("Move Back animation not found! Make sure you have it set on Character -> Basic Moves -> Move Back"); } if (!moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.moveBack.name)) { moveSetScript.PlayBasicMove(moveSetScript.basicMoves.moveBack); } } } } else if (verticalForce > 0 || !IsGrounded()) { if (move != null && controlScript.currentState == PossibleStates.Stand) { controlScript.currentState = PossibleStates.NeutralJump; } if (move == null && verticalForce / verticalTotalForce > 0 && verticalForce / verticalTotalForce <= 1) { if (isGroundBouncing) { return; } if (moveDirection == 0) { controlScript.currentState = PossibleStates.NeutralJump; } else { if (moveDirection > 0 && controlScript.mirror == -1 || moveDirection < 0 && controlScript.mirror == 1) { controlScript.currentState = PossibleStates.ForwardJump; } if (moveDirection > 0 && controlScript.mirror == 1 || moveDirection < 0 && controlScript.mirror == -1) { controlScript.currentState = PossibleStates.BackJump; } } BasicMoveInfo airAnimation = moveSetScript.basicMoves.jumpStraight; if (controlScript.currentSubState == SubStates.Stunned) { if (isWallBouncing && moveSetScript.basicMoves.airWallBounce.animMap[0].clip != null) { airAnimation = moveSetScript.basicMoves.airWallBounce; } else if (moveSetScript.basicMoves.getHitKnockBack.animMap[0].clip != null && FPMath.Abs(horizontalForce) > UFE.config.comboOptions._knockBackMinForce && UFE.config.comboOptions._knockBackMinForce > 0) { airAnimation = moveSetScript.basicMoves.getHitKnockBack; airTime *= (Fix64)2; } else { if (moveSetScript.basicMoves.getHitAir.animMap[0].clip == null) { Debug.LogError("Get Hit Air animation not found! Make sure you have it set on Character -> Basic Moves -> Get Hit Air"); } airAnimation = moveSetScript.basicMoves.getHitAir; } if (overrideStunAnimation != null) { airAnimation = overrideStunAnimation; } } else if (controlScript.isAirRecovering && (moveSetScript.basicMoves.airRecovery.animMap[0].clip != null)) { airAnimation = moveSetScript.basicMoves.airRecovery; } else { if (moveSetScript.basicMoves.jumpForward.animMap[0].clip != null && controlScript.currentState == PossibleStates.ForwardJump) { airAnimation = moveSetScript.basicMoves.jumpForward; } else if (moveSetScript.basicMoves.jumpBack.animMap[0].clip != null && controlScript.currentState == PossibleStates.BackJump) { airAnimation = moveSetScript.basicMoves.jumpBack; } else { if (moveSetScript.basicMoves.jumpStraight.animMap[0].clip == null) { Debug.LogError("Jump animation not found! Make sure you have it set on Character -> Basic Moves -> Jump Straight"); } airAnimation = moveSetScript.basicMoves.jumpStraight; } } if (!overrideAirAnimation && !moveSetScript.IsAnimationPlaying(airAnimation.name)) { moveSetScript.PlayBasicMove(airAnimation); if (airAnimation.autoSpeed) { moveSetScript.SetAnimationNormalizedSpeed(airAnimation.name, (moveSetScript.GetAnimationLength(airAnimation.name) / airTime)); } } } else if (move == null && verticalForce / verticalTotalForce <= 0) { BasicMoveInfo airAnimation = moveSetScript.basicMoves.fallStraight; if (isGroundBouncing && moveSetScript.basicMoves.fallingFromGroundBounce.animMap[0].clip != null) { airAnimation = moveSetScript.basicMoves.fallingFromGroundBounce; } else if (isWallBouncing && moveSetScript.basicMoves.airWallBounce.animMap[0].clip != null) { airAnimation = moveSetScript.basicMoves.airWallBounce; } else { if (controlScript.currentSubState == SubStates.Stunned) { if (moveSetScript.basicMoves.getHitKnockBack.animMap[0].clip != null && FPMath.Abs(horizontalForce) > UFE.config.comboOptions._knockBackMinForce && UFE.config.comboOptions._knockBackMinForce > 0) { airAnimation = moveSetScript.basicMoves.getHitKnockBack; } else { airAnimation = moveSetScript.basicMoves.getHitAir; if (moveSetScript.basicMoves.fallingFromAirHit.animMap[0].clip != null) { airAnimation = moveSetScript.basicMoves.fallingFromAirHit; } else if (moveSetScript.basicMoves.getHitAir.animMap[0].clip == null) { Debug.LogError("Air Juggle animation not found! Make sure you have it set on Character -> Basic Moves -> Air Juggle"); } } if (overrideStunAnimation != null) { airAnimation = overrideStunAnimation; } } else if (controlScript.isAirRecovering && (moveSetScript.basicMoves.airRecovery.animMap[0].clip != null)) { airAnimation = moveSetScript.basicMoves.airRecovery; } else { if (moveSetScript.basicMoves.fallForward.animMap[0].clip != null && controlScript.currentState == PossibleStates.ForwardJump) { airAnimation = moveSetScript.basicMoves.fallForward; } else if (moveSetScript.basicMoves.fallBack.animMap[0].clip != null && controlScript.currentState == PossibleStates.BackJump) { airAnimation = moveSetScript.basicMoves.fallBack; } else { if (moveSetScript.basicMoves.fallStraight.animMap[0].clip == null) { Debug.LogError("Fall animation not found! Make sure you have it set on Character -> Basic Moves -> Fall Straight"); } airAnimation = moveSetScript.basicMoves.fallStraight; } } } if (!overrideAirAnimation && !moveSetScript.IsAnimationPlaying(airAnimation.name)) { moveSetScript.PlayBasicMove(airAnimation); if (airAnimation.autoSpeed) { moveSetScript.SetAnimationNormalizedSpeed(airAnimation.name, (moveSetScript.GetAnimationLength(airAnimation.name) / airTime)); } } } } if (horizontalForce == 0 && verticalForce == 0) { moveDirection = 0; } }