LaunchCharacter和Jump不能同一帧执行
2019-05-06 本文已影响0人
我真的不知道该起什么名字了
因为Jump是给一个向上的速度, 在毎帧tick的时候获取一下, 而launchCharacter记录设置的速度, 也是在tick时候,把当前速度重置为lanunchCharacter设置的速度. 并且毎帧dojump在前, HandlePendingLaunch在后.
关键代码:
void UCharacterMovementComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction)
{
......
......
CharacterOwner->CheckJumpInput(DeltaTime);
......
PerformMovement(DeltaTime);
......
}
void UCharacterMovementComponent::PerformMovement(float DeltaSeconds)
{
......
HandlePendingLaunch();
......
}
bool UCharacterMovementComponent::DoJump(bool bReplayingMoves)
{
if ( CharacterOwner && CharacterOwner->CanJump() )
{
// Don't jump if we can't move up/down.
if (!bConstrainToPlane || FMath::Abs(PlaneConstraintNormal.Z) != 1.f)
{
Velocity.Z = FMath::Max(Velocity.Z, JumpZVelocity);
SetMovementMode(MOVE_Falling);
return true;
}
}
return false;
}