funny-prince/Source/FunnyPrince/FunnyPrinceCharacter.cpp

60 lines
1.5 KiB
C++

// Fill out your copyright notice in the Description page of Project Settings.
#include "FunnyPrinceCharacter.h"
#include "SSTCharacterMovementComponent.h"
#include "Components/InputComponent.h"
#include "EnhancedInputComponent.h"
#include "InputActionValue.h"
DEFINE_LOG_CATEGORY(LogTemplateFunnyPrinceCharacter);
//////////////////////////////////////////////////////////////////////////
// AFunnyPrinceCharacter
AFunnyPrinceCharacter::AFunnyPrinceCharacter(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}
void AFunnyPrinceCharacter::BeginPlay()
{
// Call the base class
Super::BeginPlay();
}
//////////////////////////////////////////////////////////////////////////
// Input
void AFunnyPrinceCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
// Set up action bindings
if (UEnhancedInputComponent* EnhancedInputComponent = CastChecked<UEnhancedInputComponent>(PlayerInputComponent)) {
// Punching
EnhancedInputComponent->BindAction(PunchAction, ETriggerEvent::Started, this, &AFunnyPrinceCharacter::Punch);
}
}
bool AFunnyPrinceCharacter::CanJumpInternal_Implementation() const
{
USSTCharacterMovementComponent* Movement = Cast<USSTCharacterMovementComponent>(GetCharacterMovement());
if (Movement)
{
return Super::CanJumpInternal_Implementation() || Movement->CanWalljump();
}
return Super::CanJumpInternal_Implementation();
}
void AFunnyPrinceCharacter::Punch()
{
GetCharacterMovement()->IsFalling()
}