// Update is called once per frame void Update() { if (Time.timeScale == 0) { return; } if (stunned) { bool stopStun = false; if (liftOff && hasEntityController && knockBack != Vector2.zero) { if (entityController.Grounded) { stopStun = true; } else { entityController.TargetVelocity = knockBack; } } else if (Time.time - hitTime < stunDuration) { if (hasEntityController && knockBack != Vector2.zero) { entityController.TargetVelocity = knockBack; if (!entityController.Grounded) { liftOff = true; } } } else { stopStun = true; } if (stopStun) { stunned = false; liftOff = false; moveHandler.EnterGenericState(); } } }
// Update is called once per frame void Update() { if (Time.timeScale == 0) { return; } FlagData flagData = flagHandler.Flags; Vector2 movementInput = Vector2.zero; movementInput.x = directionalInput.x; movementInput.y = directionalInput.y; //movementInput.x = Input.GetAxisRaw("Horizontal"); //movementInput.y = Input.GetAxisRaw("Vertical"); Vector2 previousTarget = entityController.TargetVelocity; Vector2 targetVelocity = Vector2.zero; foreach (InputBuffer b in inputBuffers) { b.Update(); } if ((flagData.commonFlags & CommonFlags.CanTurn) != CommonFlags.None) { if (movementInput.x != 0) { Vector3 sca = transform.localScale; if (movementInput.x > 0) { sca.x = 1; entityController.Facing = 1; } else { sca.x = -1; entityController.Facing = -1; } transform.localScale = sca; } } if ((flagData.commonFlags & CommonFlags.MoveWithInput) != CommonFlags.None) { targetVelocity.x = movementInput.x; if ((flagData.commonFlags & CommonFlags.YMovement) != CommonFlags.None) { targetVelocity.y = movementInput.y * movementSpeed; } float xSpeedMult = movementSpeed; if (!entityController.Grounded) { xSpeedMult = airMovementSpeed; } targetVelocity.x *= xSpeedMult; } if ((flagData.commonFlags & CommonFlags.MovementCancel) != CommonFlags.None) { if (movementInput.x != 0) { moveHandler.EnterGenericState("", 0.3f); } } if ((flagData.commonFlags & CommonFlags.Dodgeing) != CommonFlags.None) { if (targetVelocity == Vector2.zero) { if (previousTarget == Vector2.zero) { targetVelocity.x = entityController.Facing * movementSpeed; targetVelocity *= 6f; } else { targetVelocity = previousTarget; } } else { //targetVelocity.y /= 2f; targetVelocity *= 6f; } if (moveHandler.OverDodge != 0) { targetVelocity.y = movementSpeed; } /*animatorVec = targetVelocity; * animatorVec.x *= facing; * return animatorVec;*/ } entityController.TargetVelocity = targetVelocity; moveHandler.CheckMoves(CurrentMoves); }