Hi. I’m working on a project by myself, but I have a problem.
I’m implementing something that gives damage if I collide with a certain actor.
If they collide first, they will draw a debug sphere. Up to this point, the character moved well and also understood the actors that collided.
But suddenly after implementing the damage, the character won’t move.
The picture below has the character coming out of the building, but the camera is shining outside the building right now. It’s hard to put into words. Sorry… anyway the character never moves.
It’s the same when you play outside the building. It doesn’t move at all.
#include "InputMappingContext.h"
#include "EnhancedInputComponent.h"
#include "EnhancedInputSubsystems.h"
// Sets default values
CharacterPlayer::CharacterPlayer()
{
// Camera
SpringArm = CreateDefaultSubobject<USpringArmComponent>("SpringArm");
SpringArm->SetupAttachment(RootComponent);
Camera = CreateDefaultSubobject<UCameraComponent>("Camera");
Camera->SetupAttachment(SpringArm, USpringArmComponent::SocketName);
SpringArm->TargetArmLength = 450.0f;
SpringArm->bUsePawnControlRotation = true;
SpringArm->bInheritPitch = true;
SpringArm->bInheritRoll = true;
SpringArm->bInheritYaw = true;
SpringArm->bDoCollisionTest = true;
Camera->bUsePawnControlRotation = false;
}
void ACharacterPlayer::BeginPlay()
{
Super::BeginPlay();
APlayerController* PlayerController = CastChecked<APlayerController>(GetController());
if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PlayerController->GetLocalPlayer()))
{
Subsystem->AddMappingContext(DefaultMappingContext, 0);
}
}
// Called to bind functionality to input
void ACharacterPlayer::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
// EnhancedInputComponent를 사용하지 않는다면 에러가 나도록 체크
UEnhancedInputComponent* EnhancedInputComponent = CastChecked<UEnhancedInputComponent>(PlayerInputComponent);
if (EnhancedInputComponent)
{
EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Triggered, this, &ACharacter::Jump);
EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Completed, this, &ACharacter::StopJumping);
EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &ACharacterPlayer::Move);
EnhancedInputComponent->BindAction(LookAction, ETriggerEvent::Triggered, this, &ACharacterPlayer::Look);
EnhancedInputComponent->BindAction(AttackAction, ETriggerEvent::Triggered, this, &ACharacterPlayer::Attack);
}
}
void ACharacterPlayer::Move(const FInputActionValue& Value)
{
FVector2D MovementVector = Value.Get<FVector2D>();
const FRotator Rotation = Controller->GetControlRotation();
if (!Controller)
{
UE_LOG(LogTemp, Error, TEXT("Controller is NULL!"));
}
const FRotator YawRotation(0, Rotation.Yaw, 0);
const FVector ForwardDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
const FVector RightDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
AddMovementInput(ForwardDirection, MovementVector.X);
AddMovementInput(RightDirection, MovementVector.Y);
}
void ACharacterPlayer::Look(const FInputActionValue& Value)
{
FVector2D LookVector = Value.Get<FVector2D>();
AddControllerYawInput(LookVector.X);
AddControllerPitchInput(LookVector.Y);
}
It’s my code… I’ve done everything I can to see if the imc is set up properly, etc…
What’s weird is that after writing the damage code, it doesn’t suddenly move, so it’s the same even if you annotate all the damage code and build it again to run it.
I don’t think the damage code is the problem, please help.