CollisionMesh->DestroyComponent(); does not work

Dear experts,

I have the following code in “Projectile.cpp” for the OnHit method:

void AProjectile::OnHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, FVector NormalImpulse, const FHitResult& Hit)
{
	LaunchBlast->Deactivate();
	ImpactBlast->Activate();
	ExplosionForce->FireImpulse();

	SetRootComponent(ImpactBlast);
	CollisionMesh->DestroyComponent();

	//also get rid of projectile objects in the world
	FTimerHandle Timer;
	GetWorld()->GetTimerManager().SetTimer(Timer, this, &AProjectile::OnTimerExpire, DestroyDelay, false);
}

However when I fire the projectiles are not destroyed on impact. They keep sitting there and then disappear abpruptly once the .SetTimer() method kicks in after 10 seconds.

I have tried troubleshooting and using different methods instead of DestroyCompnent() but I can’t get it to work. I tried “DestroyPhysicsState”, “DestroyComponent(true)”.

In the Projectile_BP I unticked the “CollisionMesh” --> “Visible” but when I play I can still see the M_Metal_Rust Mesh when I shoot.

I am on version 4.22.
Any ideas are highly appreciated.

Thank you,
Peter

I just saw that in my Tank_BP the static mesh “tank_fbx_Track” was missing on the tracks. I had this bug earlier whenever I compiled C++ code. Now I set the tracks and compiled the Tank_BP and my CollisionMesh->DestroyComponent(); is now working, also unticking the “CollisionMesh” --> “Visible” is now working. I play, shoot or get shot at and it is invisible and gets destroyed when it impacts.

This bug is really (!!!) annoying. It cost me hours today, I am really frustrated, will save everything now and go to bed :frowning:
Best regards, Peter

1 Like

This is hopefully fixed for 4.23 if the pull request is accepted.

Hi Dan, I hope so. Also, all of a sudden I could not turn the tank anymore. So after a while I found out that the Track material was messed up. I had to reset the track material:
Track material:

 Friction = 0.2
 Friction Combine Mode = Min
Override Friction Combine Mode = Yes

Best regards, Peter

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms