Hi, Im new to UE programming and Im trying to bind the capsule component with my OnBeginOverlap function. Stuff doesnt work and I dont understand why.
Here is the code:
// Sets default values
Awhyyyyyyyyyyyy::Awhyyyyyyyyyyyy()
{
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don’t need it.
PrimaryActorTick.bCanEverTick = true;
GetCapsuleComponent()->InitCapsuleSize(42.0f, 96.0f);
bUseControllerRotationPitch = false;
bUseControllerRotationYaw = false;
bUseControllerRotationRoll = false;
GetCharacterMovement()->bOrientRotationToMovement = true;
GetCharacterMovement()->RotationRate = FRotator(0.0f, 540.0f, 0.0f);
GetCharacterMovement()->JumpZVelocity = 600.0f;
GetCharacterMovement()->AirControl = 0.2f;
CameraBoom = CreateAbstractDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
CameraBoom->SetupAttachment(RootComponent);
CameraBoom->TargetArmLength = 300.0f;
CameraBoom->bUsePawnControlRotation = true;
FollowCamera = CreateAbstractDefaultSubobject<UCameraComponent>(TEXT("FollowCamera"));
FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName);
FollowCamera->bUsePawnControlRotation = true;
bDead = false;
}
// Called when the game starts or when spawned
void Awhyyyyyyyyyyyy::BeginPlay()
{
Super::BeginPlay();
GetCapsuleComponent()->OnComponentBeginOverlap.AddDynamic(this, &Awhyyyyyyyyyyyy::OnBeginOverlap);
}
// Called every frame
void Awhyyyyyyyyyyyy::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// Called to bind functionality to input
void Awhyyyyyyyyyyyy::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
//allow us to look around as the character.
PlayerInputComponent->BindAxis("Turn", this, &APawn::AddControllerYawInput);
PlayerInputComponent->BindAxis("LookUp", this, &APawn::AddControllerPitchInput);
//character jump.
PlayerInputComponent->BindAction("Jump", IE_Pressed, this, &ACharacter::Jump);
PlayerInputComponent->BindAction("Jump", IE_Released, this, &ACharacter::StopJumping);
//character movement.
PlayerInputComponent->BindAxis("MoveForward", this, &Awhyyyyyyyyyyyy::MoveForward);
PlayerInputComponent->BindAxis("MoveRight", this, &Awhyyyyyyyyyyyy::MoveRight);
}
//move forward and back.
void Awhyyyyyyyyyyyy::MoveForward(float Axis){
if (!bDead) {
const FRotator Rrrrrrrrrrrrrrrotation = Controller->GetControlRotation();
const FRotator YawRotation(0, Rrrrrrrrrrrrrrrotation.Yaw, 0);
const FVector Dddddddddddddddddddd = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
AddMovementInput(Dddddddddddddddddddd, Axis);
}
}
//move right and left
void Awhyyyyyyyyyyyy::MoveRight(float Axis){
if (!bDead) {
const FRotator Rrrrrrrrrrrrrrrotation = Controller->GetControlRotation();
const FRotator YawRotation(0, Rrrrrrrrrrrrrrrotation.Yaw, 0);
const FVector Dddddddddddddddddddd = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
AddMovementInput(Dddddddddddddddddddd, Axis);
}
}
void Awhyyyyyyyyyyyy::OnBeginOverlap(UPrimitiveComponent* HitComp ,UPrimitiveComponent* OtherComp, AActor* OtherActor,
int32 OtherBodyIndex, bool bFromSwip,
const FHitResult& SweepResult){
if (OtherActor->ActorHasTag("Recharge")) {
UE_LOG(LogTemp, Warning, TEXT("Collided with"));
}
}
And here is the error:
Severity Code Description Project File Line Suppression State
Error (active) E0304 no instance of function template “FComponentBeginOverlapSignature::__Internal_AddDynamic” matches the argument list cgame C:\Users\Itamar\Desktop\games\cgame\Source\cgame\whyyyyyyyyyyyy.cpp 42
Thanks for your help.