Hello,
I have review my code a couple times over, but I’m stumped for now as why OnHit isn’t being called during play. This is my code:
CPP
UTankTrack::UTankTrack()
{
PrimaryComponentTick.bCanEverTick = true;
}
// Called when the game starts
void UTankTrack::BeginPlay()
{
OnComponentHit.AddDynamic(this, &UTankTrack::OnHit);
}
void UTankTrack::OnHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, FVector NormalImpulse, const FHitResult& Hit)
{
UE_LOG(LogClass, Warning, TEXT("I'm hit..."));
}
HEADER
UCLASS(ClassGroup = (Tank), meta = (BlueprintSpawnableComponent), hidecategories = ("Lighting"))
class BATTLETANKS_API UTankTrack : public UStaticMeshComponent
{
GENERATED_BODY()
public:
UTankTrack();
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
virtual void BeginPlay() override;
UFUNCTION(BlueprintCallable, Category = Input)
void SetThrottle(float throttle);
//In newtons (N)
UPROPERTY(EditDefaultsOnly)
float maxDrivingForce = 400000; //10m/s^2
private:
UFUNCTION()
void OnHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, FVector NormalImpulse, const FHitResult& Hit);
};
I’m running 4.15.2. Is it possible they changed it again? Any help is appreciated!