bool USFCharacterMovementComponent::DoJump(bool bReplayingMoves)
{
	GravityScale = 5;
	
	if (CharacterOwner && CharacterOwner->CanJump())
	{
		// Don't jump if we can't move up/down.
		if (!bConstrainToPlane || FMath::Abs(PlaneConstraintNormal.Z) != 1.f)
		{
			Velocity.Z = JumpZVelocity;
			
			auto owner = Cast<ASUPERFASTCharacter>(CharacterOwner);
			if (owner && IsFalling())
			{
				owner->mayDoubleJump = false;

				if (owner->wallSlideBit == 1)
				{
					Velocity.X = JumpZVelocity * -0.7;
				}
				else if (owner->wallSlideBit == 2)
				{
					Velocity.X = JumpZVelocity * 0.7;
				}
				owner->wallSlideBit = 0;
			}

			SetMovementMode(MOVE_Falling);

			return true;
		}
	}

	return false;
}
示例#2
0
void UMyAnimInstance::NativeUpdateAnimation(float DeltaSeconds)
{
	Super::NativeUpdateAnimation(DeltaSeconds);

	const auto PawnOwner = TryGetPawnOwner();
	if (nullptr != PawnOwner)
	{
		//!< スピード
		const auto Velocity = PawnOwner->GetVelocity();
		Speed = Velocity.Size();

		//!< 方向
		Direction = (Velocity.Rotation() - PawnOwner->GetActorRotation()).Yaw;
		while (Direction < -180.0f)
		{
			Direction += 360.0f;
		}
		while (Direction > 180.0f)
		{
			Direction -= 360.0f;
		}

		//!< 落下
		const auto MovementComp = PawnOwner->GetMovementComponent();
		if (nullptr != MovementComp)
		{
			IsFalling = MovementComp->IsFalling();
		}
	}
}
void USFCharacterMovementComponent::Crouch(bool bClientSimulation)
{
	Super::Crouch(bClientSimulation);
	BrakingFrictionFactor = 0.07;

	if (!IsFalling() && Velocity.GetAbs().X <= 1000.0 && Velocity.GetAbs().X > 0.0) {
		Velocity.X += ((Velocity.X > 0) ? 1 : -1) * 1000.0;
	}
}
示例#4
0
bool ANimModCharacter::IsInAir() const
{
	return IsFalling() || IsJumping();
}