Hello, I try to implement jumping for a pawn similarly as moving with WSAD keys. The function is revoke when player hits space-bar. All it does is moving object a little bit over ground level and the it immediately falls down. Height of jump is not associated with the value I multiply with the result of GetActorUpVector() function. Why is it like that? Is this ide of implementing jumping correct or should I use an impulse or force to do it?
void AMySphere::Jump()
{
if (OurMovementComponent && (OurMovementComponent->UpdatedComponent == RootComponent)) {
OurMovementComponent->AddInputVector(GetActorUpVector() * SOME_VALUE);
}
}
void AMySphere::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
PlayerInputComponent->BindAxis("MoveForward", this, &AMySphere::MoveForward);
PlayerInputComponent->BindAxis("MoveRight", this, &AMySphere::MoveRight);
PlayerInputComponent->BindAxis("Turn", this, &AMySphere::Turn);
PlayerInputComponent->BindAxis("LookUp", this, &AMySphere::LookUp);
PlayerInputComponent->BindAction("Jump", IE_Pressed, this, &AMySphere::Jump);
}