void ABaseCharacter::ApplyPhysicsToTheRagdolledBody(FDamageEvent const& DamageEvent) { if (bRagdolledAfterDeath) { USkeletalMeshComponent* Mesh3P = GetMesh(); if (Mesh3P) { /* Apply physics impulse on the bone of the enemy skeleton mesh we hit (ray-trace damage only) */ if (DamageEvent.IsOfType(FPointDamageEvent::ClassID)) { FPointDamageEvent PointDmg = *((FPointDamageEvent*)&DamageEvent); // TODO: Use DamageTypeClass->DamageImpulse Mesh3P->AddImpulseAtLocation(PointDmg.ShotDirection * 12000, PointDmg.HitInfo.ImpactPoint, PointDmg.HitInfo.BoneName); } if (DamageEvent.IsOfType(FRadialDamageEvent::ClassID)) { FRadialDamageEvent RadialDmg = *((FRadialDamageEvent const*)(&DamageEvent)); Mesh3P->AddRadialImpulse(RadialDmg.Origin, RadialDmg.Params.GetMaxRadius(), 100000 /*RadialDmg.DamageTypeClass->DamageImpulse*/, ERadialImpulseFalloff::RIF_Linear); } } } }
void UDestructibleComponent::ReceiveComponentDamage(float DamageAmount, FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser) { UDamageType const* const DamageTypeCDO = DamageEvent.DamageTypeClass ? DamageEvent.DamageTypeClass->GetDefaultObject<UDamageType>() : GetDefault<UDamageType>(); if (DamageEvent.IsOfType(FPointDamageEvent::ClassID)) { FPointDamageEvent const* const PointDamageEvent = (FPointDamageEvent*)(&DamageEvent); ApplyDamage(DamageAmount, PointDamageEvent->HitInfo.ImpactPoint, PointDamageEvent->ShotDirection, DamageTypeCDO->DestructibleImpulse); } else if (DamageEvent.IsOfType(FRadialDamageEvent::ClassID)) { FRadialDamageEvent const* const RadialDamageEvent = (FRadialDamageEvent*)(&DamageEvent); ApplyRadiusDamage(DamageAmount, RadialDamageEvent->Origin, RadialDamageEvent->Params.OuterRadius, DamageTypeCDO->DestructibleImpulse, false); } }
void AShooterCharacter::OnDeath(float KillingDamage, FDamageEvent const& DamageEvent, APawn* PawnInstigator, AActor* DamageCauser) { if (bIsDying) { return; } bReplicateMovement = false; bTearOff = true; bIsDying = true; PlayHit(KillingDamage, DamageEvent, PawnInstigator, DamageCauser, true); DetachFromControllerPendingDestroy(); /* Disable all collision on capsule */ UCapsuleComponent* CapsuleComp = GetCapsuleComponent(); CapsuleComp->SetCollisionEnabled(ECollisionEnabled::NoCollision); CapsuleComp->SetCollisionResponseToAllChannels(ECR_Ignore); USkeletalMeshComponent* Mesh3P = GetMesh(); if (Mesh3P) { Mesh3P->SetCollisionProfileName(TEXT("Ragdoll")); } SetActorEnableCollision(true); SetRagdollPhysics(); /* Apply physics impulse on the bone of the enemy skeleton mesh we hit (ray-trace damage only) */ if (DamageEvent.IsOfType(FPointDamageEvent::ClassID)) { FPointDamageEvent PointDmg = *((FPointDamageEvent*)(&DamageEvent)); { // TODO: Use DamageTypeClass->DamageImpulse Mesh3P->AddImpulseAtLocation(PointDmg.ShotDirection * 12000, PointDmg.HitInfo.ImpactPoint, PointDmg.HitInfo.BoneName); } } if (DamageEvent.IsOfType(FRadialDamageEvent::ClassID)) { FRadialDamageEvent RadialDmg = *((FRadialDamageEvent const*)(&DamageEvent)); { Mesh3P->AddRadialImpulse(RadialDmg.Origin, RadialDmg.Params.GetMaxRadius(), 100000 /*RadialDmg.DamageTypeClass->DamageImpulse*/, ERadialImpulseFalloff::RIF_Linear); } } }
/** Called when this component receives damage */ void UFluidSurfaceComponent::ReceiveComponentDamage( float DamageAmount, FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser ) { Super::ReceiveComponentDamage( DamageAmount, DamageEvent, EventInstigator, DamageCauser ); FVector HitLocation; if( DamageEvent.IsOfType( FPointDamageEvent::ClassID ) ) { FPointDamageEvent const* const PointDamageEvent = (FPointDamageEvent*) ( &DamageEvent ); Pling( PointDamageEvent->HitInfo.ImpactPoint, ShootStrength, ShootRadius ); HitLocation = PointDamageEvent->HitInfo.ImpactPoint; } if( ShootEffect ) { /* Spawn shoot effect emitter */ FRotator Rotation = FRotator( 0, 0, 0 ); AEmitter* Emitter = GetWorld( )->SpawnActor<AEmitter>( HitLocation, Rotation ); Emitter->ParticleSystemComponent->SetTemplate( ShootEffect ); } }