Trying to make this work for clients. So far everything works, just that the client mesh does not rotate well (example: Screen capture - bac2505af57ebba858cfe14e97778302 - Gyazo ). I think there are parts where the client runs the variables twice, which causes the character to spas out when moving more then 90 degrees? I am running out of ideas and have tried cutting this in segments. I made the capsule component replicate which improved the rotation a tad.
Also did this in c++ if it’s more easier to fix and understand:
void AVSCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
/*
if (Role == ROLE_Authority)
{
FRotator MakeRot = UKismetMathLibrary::MakeRotator(0.0f, Pitch1, Yaw1);
FRotator ControlRotation = this->GetControlRotation();
FRotator ActorRotation = this->GetActorRotation();
FRotator DeltaRotation = UKismetMathLibrary::NormalizedDeltaRotator(ControlRotation, ActorRotation);
FRotator Interpto = FMath::RInterpTo(MakeRot, DeltaRotation, GetWorld()->GetDeltaSeconds(), 8.0f);
Yaw1 = Interpto.Yaw;
Pitch1 = Interpto.Pitch;
//Other Section
//FVector CurrentVel = this->GetVelocity();
//float vectorLength = CurrentVel.Size(); //vector length
if (GetCharacterMovement()->Velocity.Size() == 0)
{
Moving1 = true;
}
else
Moving1 = false;
UE_LOG(LogTemp, Log, TEXT(“Health Changed: %s”), *FString::SanitizeFloat(Moving1));
if (Moving1 == true)
{
GetCharacterMovement()->bUseControllerDesiredRotation = false;
FRotator ControlRotation2 = this->GetControlRotation();
FRotator ActorRotation2 = this->GetActorRotation();
ControlRotation2.Roll = 0;
ControlRotation2.Pitch = 0;
ActorRotation2.Roll = 0;
ActorRotation2.Pitch = 0;
FRotator DeltaRotation2 = UKismetMathLibrary::NormalizedDeltaRotator(ControlRotation2, ActorRotation2);
float absfloat = abs(DeltaRotation2.Yaw);
FRotator Interpto = FMath::RInterpTo(FRotator(0.0f, 0.0f, 0.0f), DeltaRotation2, GetWorld()->GetDeltaSeconds(), 10.0f);
if (AimOffset1 || absfloat >= 90.0f)
{
AimOffset1 = true;
AddActorWorldRotation(Interpto);
bool NearlyEqual = UKismetMathLibrary::NearlyEqual_FloatFloat(DeltaRotation2.Yaw, 0.0f, 1.0f);
AimOffset1 = !NearlyEqual;
}
}
else
{
GetCharacterMovement()->bUseControllerDesiredRotation = true;
AimOffset1 = false;
}
}*/
}