OnHit doesn't tick

I copied the code from ben’s github but it still doesn’t work and I have enabled simulation generates hit events. what should I do?

Hi. I was having the same problem. Then I realised that every compilation my Tank blueprint gets reset. What I did is, set all paramaters again. On tracks, check that Simulation Generates Hit Events under collision is checked.

2 Likes

You actually can just in TankTrack Construction type in SetNotifyRigidBodyCollision(true);. This way you won’t have to change bp setting over and over again in every compilation.

So what is the case when the box is Checked and we are using SetNotifyRigidBodyCollision(true) in the constructor and still am not getting a hit event?

Also had the problem of disappearing static meshes after compilation as a few times before. Had to delete the tracks and add them back in.

Are we supposed to have colliders on the tracks? I remember us having to remove them early on

void UTankTrack::BeginPlay()
{
	Super::BeginPlay();

	OnComponentHit.AddDynamic(this, &UTankTrack::OnHit);

}

void UTankTrack::OnHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, FVector NormalImpulse, const FHitResult& Hit)
{
	UE_LOG(LogTemp, Warning, TEXT("OnHit event"));
	DriveTrack();
	SlipCorrection();
	CurrentThrottle = 0;
}

Privacy & Terms