1
\$\begingroup\$

For some reason it applies full damage even when actor to damage is further than 100.0f from the MainDamageSphere. What can be the problem? I'm checking for damage with the usage of overriden "TakeDamage" function

AGrenadePauncherProjectile_CPP::OnHit

void AGrenadeLauncherProjectile_CPP::OnHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp,
                                           FVector NormalImpulse, const FHitResult& Hit)
{
    if (OtherActor != nullptr && OtherActor != this)
    {
        TArray<AActor*> ActorsToIgnore;

        /*UGameplayStatics::ApplyRadialDamageWithFalloff(OtherActor, Damage, 1.0f, Hit.ImpactPoint, 100, 400,
            1.0f, UDamageType::StaticClass(), ActorsToIgnore);*/

        ExplosionClass->Initialize(SplashRadius, 100.0f, Damage, GetTransform(), OtherActor, ActorsToIgnore, this);

        SoundSystem->PlaySoundUnsafe(*ExplosionSoundCue, GetActorLocation());
    }

    Destroy();
}

UExplosion::Initialize

void UExplosion::Initialize(const float& SphereRadiusValue, const float& SphereRadiusValueInner, const float& SplashDamageValue, 
                            const FTransform Transform, AActor* ToDamage, TArray<AActor*> ActorsToIgnore, AActor* ProjectileActor)
{
    if (ExplosionParticleSystem)
    {
        UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), ExplosionParticleSystem, Transform, true, EPSCPoolMethod::None, true);

        // decided to hardcode parameters for debug
        UGameplayStatics::ApplyRadialDamageWithFalloff(ToDamage, SplashDamageValue, 1.0f, Transform.GetLocation(), 100, 400,
                                                       1.0f, UDamageType::StaticClass(), ActorsToIgnore, ProjectileActor);
    }       
}

UPDATE

As far as I can see from disassembled code, ApplyRadialDamageWithFaloff calls procedure TakeDamage that belongs to my enemy actor(which needs to be damaged) and passes base damage instead of calculating new value relying on enemy's position inside of sphere... I attach a screenshot of disassembled code where you can see that xmm6 vector register holds a m128_f32 variable that has base damage and it moves it to xmm1(which is a register related to TakeDamage function)

So what's the problem? Why would the main function refuse to calculate new value depending on enemy ator distance from impact point?

enter image description here

\$\endgroup\$
5
  • \$\begingroup\$ Sanity check: Which entity/point are you getting the location of with Transform.GetLocation()? Docs say that should be the center of the blast. \$\endgroup\$
    – Basic
    Commented Jul 4, 2023 at 16:37
  • \$\begingroup\$ @Basic I pass a FTransform of a grenade launcher projectile when it hits something(OnHit). I assume that this is an "end point" for my projectile, so I pass its transform to the ExplosionClass that spawns an explosion emitter and applies radial damage \$\endgroup\$ Commented Jul 4, 2023 at 16:47
  • 1
    \$\begingroup\$ @Basic guess I'll provide full code \$\endgroup\$ Commented Jul 4, 2023 at 16:49
  • \$\begingroup\$ I wish I could help but I'm not intimately familiar with UE4, I was just trying to cover some of the low-hanging fruit. \$\endgroup\$
    – Basic
    Commented Jul 4, 2023 at 18:31
  • \$\begingroup\$ @Basic never mind, I've already solved the problem. Thank you very much for your attention, pal, I really appreciate that \$\endgroup\$ Commented Jul 4, 2023 at 18:43

1 Answer 1

1
\$\begingroup\$

Just had to switch from simple TakeDamage to OnTakeRadialDamage and OnTakePointDamage. The problem was solved.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .