Just As the title says. I’m trying to rotate a character 180° when a collision box detects an Actor ( more specifically a World Static Object).
I have a AddMovementInput(FVector(1.0f, 0.0f, 0.0f), 0.25f); always being called on OnTick()
The method in cuestion TurnCharacter() has a GetCharacterLocation() and a AddMovementInput() methods.
Here is the problem, the TurnCharacter Metod triggers butboth methods don’t.
Ive tried ir on blueprint and it doesn’t work either.
Constructor for the box
//box that checks for a wall, will change directions when so
FrontCollisionBox = CreateDefaultSubobject<UBoxComponent>(TEXT("WallDetection"));
FrontCollisionBox->SetupAttachment(RootComponent);
FrontCollisionBox->OnComponentBeginOverlap.AddUniqueDynamic(this, &AEnemyPaperCharacter::OnBeginOverlapComponentEvent);
FrontCollisionBox->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
FrontCollisionBox->SetCollisionResponseToAllChannels(ECR_Ignore);
FrontCollisionBox->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
FrontCollisionBox->SetCollisionResponseToChannel(ECC_WorldStatic,ECR_Overlap);
OnBeginOverlapEvent method and on Tick method
void AEnemyPaperCharacter::Tick(float DeltaTime)
{
//Character is always moving Forward
AddMovementInput(FVector(1.0f, 0.0f, 0.0f), 0.25f);
}
void AEnemyPaperCharacter::UpdateAnimation()
{
}
void AEnemyPaperCharacter::OnBeginOverlapComponentEvent(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSwep,
const FHitResult& SweepResult)
{
//when collision box hits world static component
//the direction of the movement vector is inverted
UE_LOG(LogTemp, Warning, TEXT("On component overlap called"));
TurnCharacter();
}
TurnCharacter()
void AEnemyPaperCharacter::TurnCharacter()
{
SetActorRotation(FRotator(0.0f, 1800.0f, 0.0f));
FVector Forward = GetActorForwardVector();
AddMovementInput(Forward, 0.25f);
UE_LOG(LogTemp, Warning, TEXT("TurnCharacter called"));