public void FixUpdate() { _curPlayerState.FixedUpdate(_rigidbody); _rigidbody.position += _controller.AnimMovePos; _controller.AnimMovePos = Vector3.zero; }
public void FixedUpdate() { // Cache not used yet cacheUsedThisUpdate = false; // Fixedupdate might run several times per frame to "catch up" with the rest of input hasFinalizedCacheBeenUsedOnce = true; // Make a copy of the finalized cache // After using, only the "key hold" commands (to be executed multiple times between updates) // + any remaining commands from the clone should be in the finalized cache Dictionary <ECommandType, Queue <ICommand> > cloneCache = new Dictionary <ECommandType, Queue <ICommand> >(finalizedCache); // Use a new gravity scale for this update currentGravityScale = playerCharacter.defaultGravityScale; playerCharacter.rigidBody.gravityScale = currentGravityScale; // Create a new list of gravity manipulators for one frame, so that a double'd input doesn't change the gravity twice grvManipulatorsThisFrame = new Dictionary <EInputControls, float>(); HashSet <Type> usedStateClasses = new HashSet <Type>(); while (true) { //MonoBehaviour.print(currentState.ToString()); // Check if the current state wants to switch or if the update wants to switch in the middle of the update if (currentState.check() && (cacheUsedThisUpdate || currentState.FixedUpdate(cloneCache))) { // If the check was good and the fixedupdate finished, we are done with this full FixedUpdate call break; } // Prevent infinite loop if (usedStateClasses.Contains <Type>(currentState.getNextState().GetType())) { break; } // Otherwise we switch states and keep executing currentState.exit(); currentState = currentState.getNextState(); currentState.enter(); // Add to list of used states usedStateClasses.Add(currentState.GetType()); } cacheUsedThisUpdate = true; }
private void FixedUpdate() { if (actor.collisions.bellow || actor.collisions.above) { if (!actor.collisions.slidingSlope) { velocity.y = 0; } } if (state is PlayerLedgeGrab) { velocity.y = 0; } else { velocity.y -= settings.gravity * Time.deltaTime; velocity.y = Mathf.Clamp(velocity.y, -settings.maxFallSpeed, Mathf.Infinity); } if (velocity.x > 0) { if (xVelocitySign != 1) { xVelocitySign = 1; } } else if (velocity.x < 0) { if (xVelocitySign != -1) { xVelocitySign = -1; } } actor.Move(velocity, Time.fixedDeltaTime); state.FixedUpdate(this); if (attackState != null) { attackState.FixedUpdate(this); } GameManager.Instance.AddMetaFloat( input.id == 1 ? MetaTag.PLAYER_1_DISTANCE : MetaTag.PLAYER_2_DISTANCE, actor.collisions.move.magnitude ); }
private void FixedUpdate() { playerState.FixedUpdate(input, Time.fixedDeltaTime); }