Hey everyone, so I’ve been having this issue with my game and this double jump function I have. I intended for the double jump to allow for a mid air direction change depending on where you wanted to move. While the function works properly on the server, the client’s doesn’t work. I made the double jump function run on the Server already so I’m not sure what else to do. Can anyone help? I was thinking I could make a client side function that would get the client’s CharacterMovementComponent and then perform the modifications on the server, but I’m not entirely sure if that’s right.
BaseCharacter.cpp
void ABaseCharacter::DoubleJump_Implementation()
{
// Get CharacterMovement component
UCharacterMovementComponent* CharMovement = ABaseCharacter::GetCharacterMovement();
bool check = CharMovement->IsFalling();
// If the player is in the air and has not already double jumped...
if (check && !(HasAirJumped) && !(IsDodging))
{
// kill the player's velocity
CharMovement->Velocity = FVector(0.0, 0.0, 0.0);
//PLACEHOLDER
float forward_val = 1.0;
float right_val = 1.0;
// If the player is pressing any movement key
if (forward_val != 0.0 || right_val != 0.0)
{
// get the current velocity
FVector currvelocity = CharMovement->Velocity;
// calculate the new velocity
FVector additional_movement = (GetActorForwardVector() * DoubleJumpHeight * forward_val) + (GetActorRightVector() * DoubleJumpHeight * right_val);
// set the player's new velocity
CharMovement->Velocity = FVector(currvelocity.X + additional_movement.X, currvelocity.Y + additional_movement.Y, currvelocity.Z);
}
// if no keys are being pressed
else
{
FVector currvelocity = CharMovement->Velocity;
//CharMovement->Velocity = FVector(currvelocity.X, currvelocity.Y, currvelocity.Z + JumpHeight);
// 2nd version: player loses all X and Y velocity
CharMovement->Velocity = FVector(0.0, 0.0, currvelocity.Z);
}
}
}
bool ABaseCharacter::DoubleJump_Validate()
{
return true;
}
I have this in the BaseCharacter.h
UFUNCTION(Server, Reliable, WithValidation, BlueprintCallable, Category = "Jump")
void DoubleJump();