Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FVector UCustomMovementComponent::ComputeSlideVector(const FVector& Delta, const float Time, const FVector& Normal, const FHitResult& Hit) const
- {
- // Delta Input is basically just Velocity.
- if (!bConstrainToPlane)
- {
- FVector impactProject = FVector::VectorPlaneProject(Normal, FVector(0.f, 0.f, 1.f)).GetSafeNormal();
- FVector wishDir = InputDirection;
- FVector ForwardVector = CharacterOwner->GetActorForwardVector();
- float EffectiveAngle = FMath::Abs(FVector::DotProduct(-impactProject, wishDir));
- if (CharacterOwner->GetLocalRole() == ROLE_Authority)
- {
- // Always Zero
- GEngine->AddOnScreenDebugMessage(1, 1.f, FColor::Green, FString::Printf(TEXT("Server: %s"), *wishDir.ToString()));
- }
- else
- {
- GEngine->AddOnScreenDebugMessage(2, 1.f, FColor::Red, FString::Printf(TEXT("Client: %s"), *wishDir.ToString()));
- }
- float velocityScale = Delta.Size();
- FVector newAngle = FMath::Lerp(Delta, ForwardVector, EffectiveAngle).GetSafeNormal();
- newAngle *= velocityScale;
- FVector newReturn = FVector::VectorPlaneProject(newAngle, Normal) * Time;
- return newReturn;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement