I just created my custom gamemode which worked fine and my custom character which doesn’t seem to work. I get no errors but it just doesn’t work. Here is my code:
CPP
#include “Game.h”
#include “CustomCharacter.h”
ACustomCharacter::ACustomCharacter(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
}
void ACustomCharacter::SetupPlayerInputComponent(UInputComponent* InputComponent)
{
InputComponent->BindAxis("CameraAxisX", this, &ACustomCharacter::AddControllerYawInput);
InputComponent->BindAxis("CameraAxisY", this, &ACustomCharacter::AddControllerPitchInput);
InputComponent->BindAxis("MovementAxisX", this, &ACustomCharacter::MoveX);
InputComponent->BindAxis("MovementAxisY", this, &ACustomCharacter::MoveY);
InputComponent->BindAction("Jump", IE_Pressed, this, &ACustomCharacter::OnStartJump);
InputComponent->BindAction("Jump", IE_Released, this, &ACustomCharacter::OnStopJump);
}
void ACustomCharacter::MoveX(float Value)
{
if ((Controller != NULL) && (Value != 0.0f))
{
FRotator Rotation = Controller->GetControlRotation();
if (CharacterMovement->IsMovingOnGround() || CharacterMovement->IsFalling())
{
Rotation.Pitch = 0.0f;
}
const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::X);
AddMovementInput(Direction, Value);
}
}
void ACustomCharacter::MoveY(float Value)
{
if ((Controller != NULL) && (Value != 0.0f))
{
const FRotator Rotation = Controller->GetControlRotation();
const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::Y);
AddMovementInput(Direction, Value);
}
}
void ACustomCharacter::OnStartJump()
{
bPressedJump = true;
}
void ACustomCharacter::OnStopJump()
{
bPressedJump = false;
}
H
#pragma once
#include "GameFramework/Character.h"
#include "CustomCharacter.generated.h"
UCLASS()
class GAME_API ACustomCharacter
: public ACharacter
{
GENERATED_UCLASS_BODY()
protected:
virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;
UFUNCTION()
void MoveX(float Val);
UFUNCTION()
void MoveY(float Val);
UFUNCTION()
void OnStartJump();
UFUNCTION()
void OnStopJump();
};
I initialize it on my gamemode like this: DefaultPawnClass = ACustomCharacter::StaticClass();
Im using the 4.3.1 version, Im sure default gamemode is set to my gamemode and all of the binds i have are created on engine too.
Any help will be appreciated,
Thanks