i have a simple melee weapon c++ actor with a SkeletalMeshComponent that is set up in a blueprint deriving from the AWeapon C++ class.
void AWeapon::NotifyHit(UPrimitiveComponent* MyComp, AActor* Other, UPrimitiveComponent* OtherComp, bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult& Hit)
{
GEngine->AddOnScreenDebugMessage(-1, 1.5f, FColor::Blue, FString("hit"));
}
The weapon actor has simulate physics OFF while equipped and attached to the player and ON when its on the ground waiting to be picked up. The weapon actor is then attached to the player actor and WeaponMesh->SetSimulatePhysics(false);
is called to prevent the weapon from flying out of the players hand.
This works great for when i hit (play a swinging animation) objects that have âsimulate physicsâ enabled, for example can hit a block with a shovel and it flys in correct direction. however i get no notifications for static objects with collision but not âsimulate physicsâ checked (like walls for example).
How could i detect hits on static objects with NotifyHit as well?
Also what is the difference between WeaponMesh->OnComponentHit.AddDynamic(this, &AWeapon::OnHit);
vs overriding the actors notifyhit ? I saw the sample projectile uses OnComponentHit but that is also not triggering an event for me on static walls like it does with the projectile example