I am trying to implement multiplayer
I am using PlayerController class to move my characters.
.cpp:
where i call functions
void ASquadPlayerController::SetupInputComponent()
{
Super::SetupInputComponent();
check(InputComponent);
// Right Joystick Input
InputComponent->BindAxis("TurnRate", this, &ASquadPlayerController::RotateForward);
InputComponent->BindAxis("LookUpRate", this, &ASquadPlayerController::RotateYaw);
}
// the functions below here
void ASquadPlayerController::RotateForward(float Value)
{
// Setting the Control Rotation on Input
if (Value != 0.0f)
{
UGameplayStatics::GetPlayerCharacter(GetWorld(),0)->GetCharacterMovement()->bOrientRotationToMovement = false;
RotAxisValueX = GetInputAxisValue("TurnRate");
RotAxisValueY = GetInputAxisValue("LookUpRate");
ControllerVec.Y = RotAxisValueX;
ControllerVec.X = RotAxisValueY;
ControllerRot = UKismetMathLibrary::MakeRotFromX(ControllerVec);
SetControlRotation(ControllerRot);
}
else
{
UGameplayStatics::GetPlayerCharacter(GetWorld(),0)->GetCharacterMovement()->bOrientRotationToMovement = false; // change this
//GetCharacter()->GetCharacterMovement()->bOrientRotationToMovement = true; // this is where exactly crash happens
UGameplayStatics::GetPlayerCharacter(GetWorld(),0)->bUseControllerRotationYaw = false;
}
}
and the .h file
UFUNCTION(BlueprintAuthorityOnly, Category = "Controller")
void RotateForward(float Value);
UFUNCTION(BlueprintAuthorityOnly, Category = "Controller")
void RotateYaw(float Value);
//Required
virtual void SetupInputComponent() override;
–
the crash screen:
