Hi
I want to make a simple first person shooter but I have some problems with the axis and action binding.
To bind the functions LookUp and OnFire dosn’t work but the rest does. I althoug doesn’t get any compiling errors. I recompiled and reopened the unreal editor and vs, but it didn’t worked.
AFps is a Character and this is the code in FpsChar.cpp to bind the functions.
void AFpsChar::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
check(InputComponent);
InputComponent->BindAxis("MoveForward", this, &AFpsChar::MoveForward);
InputComponent->BindAxis("MoveRight", this, &AFpsChar::MoveRight);
InputComponent->BindAxis("LookUp", this, &AFpsChar::LookUp);
InputComponent->BindAxis("LookRight", this, &AFpsChar::LookRight);
InputComponent->BindAction("sayHi", IE_Pressed, this, &AFpsChar::SayHi);
InputComponent->BindAction("Jump", IE_Pressed, this, &AFpsChar::StartJump);
InputComponent->BindAction("Jump", IE_Released, this, &AFpsChar::StopJump);
InputComponent->BindAction("Fire", IE_Pressed, this, &AFpsChar::OnFire);
}
This is the declarations off the functions OnFire and LookUp in the .h
void LookUp(float fVal);
void OnFire();
And this is the definition for the functions in the .cpp
void AFpsChar::LookUp(float fVal)
{
GEngine->AddOnScreenDebugMessage(1, 1.5, FColor::Black, "lookUp");
//lets the cam look up
AddControllerPitchInput(fVal);
}
void AFpsChar::OnFire()
{
GEngine->AddOnScreenDebugMessage(1, 1.5, FColor::Black, "OnFire");
if (projectileClass != NULL)
{
//get controlrotation and save in var
const FRotator spawnRotation = GetControlRotation();
//get the location where the projectile should be spawnd
const FVector vSpawnLocation = ((projectileSpawnPosition != nullptr) ? projectileSpawnPosition->GetComponentLocation(): GetActorLocation());
UWorld* const world= GetWorld();
if (world != nullptr)
{
//spawn projectile at location
world->SpawnActor<AFpPronectile>(projectileClass, vSpawnLocation, spawnRotation);
}
}
}
I if you have any idea I would be happy for it.
Thanks : )