# Newbie needing help plz and thanks

**URL:** <https://forums.unrealengine.com/t/newbie-needing-help-plz-and-thanks/132873>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [November 1, 2019, 8:28pm UTC](https://forums.unrealengine.com/t/newbie-needing-help-plz-and-thanks/132873 "2019-11-01T20:28:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheMaker\_AC](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TheMaker\_AC](https://forums.unrealengine.com/u/TheMaker_AC)\
**Post date:** [November 1, 2019, 8:28pm UTC](https://forums.unrealengine.com/t/newbie-needing-help-plz-and-thanks/132873/1 "2019-11-01T20:28:05Z")

</div>

Hi, I’m trying to follow along with this [tutorial](https://www.youtube.com/watch?v=5XiBnL4W-mM) Time stamp in video is 11.00 to 14.00 but finding it slightly hard as i’m new to Unreal 4. I’m trying to follow along but dunno where it has gone wrong, I know he has done it in a previous version from 4.22.3 (currenly using). If someone is willing to spend a little bit of time to help me i would be very greatful.

```auto

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

    FTimerHandle T_Handle;
    //GetWorld()->GetTimerManager().SetTimer(T_Handle, this, &AG_nadeProjectile::OnDetonate, 5.f, false);

}

void AG_nadeProjectile::OnDetonate()
{
    UParticleSystemComponent* Explosion = UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), ExplosionParticies, GetActorTransform());
    //Explosion->SetRelativeScale3D(FVector(4.f));
    //Explosion
    //UGameplayStatics::PlaySoundAtLocation(GetWorld(), ExplosionSound, GetActorLocation());
    //UGameplayStatics::PlaySoundAtLocation();

    TArray<FHitResult> HitActors;

    FVector StartTrace = GetActorLocation();
    FVector EndTrace = StartTrace;
    EndTrace.Z += 300.f;

    FCollisionShape CollisionShape;
    CollisionShape.ShapeType = ECollisionShape::Sphere;
    CollisionShape.SetSphere(Radius);

    if (GetWorld()->SweepMultiByChannel(HitActors, StartTrace, EndTrace, FQuat::FQuat(), ECC_WorldStatic, CollisionShape))
    {
        for (auto Actors = HitActors.CreateIterator(); Actors; Actors++)
        {
            UStaticMeshComponent* SM = Cast<UStaticMeshComponent>((*Actors).Actor->GetRootComponent());
            ADestructibleActor* DA = Cast<ADestructibleActor>((*Actors).GetActor());

            if (SM)
            {

                SM->ApplyRadialDamage(GetActorLocation(), 140, 10, ERadialImpulseFalloff::RIF_Linear, false);
            }
            else if(DA)
            {
                DA->GetDestructibleComponent()->ApplyRadialDamage(10.f, Actors->ImpactPoint, 500.f, 3000.f, false);
            }

        }

    }

    Destroy();

}

```

 ![Capture.PNG](https://d3kjluh73b9h9o.cloudfront.net/original/3X/0/3/03613511fecd5c255bfac874b8aab8cbec9a213d.png)

---

<div class="post-metadata">

**Author:** ![SolidSk](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/solidsk/32/1194513_2.png) [@SolidSk](https://forums.unrealengine.com/u/SolidSk)\
**Post date:** [November 2, 2019, 4:57am UTC](https://forums.unrealengine.com/t/newbie-needing-help-plz-and-thanks/132873/2 "2019-11-02T04:57:02Z")

</div>

Hi,  
The C2027 error is probably that you need to include this in your **G\_nadeProjectile.cpp** file:

**#include "DestructibleComponent.h"**

[https://docs.unrealengine.com/en-US/API/Plugins/ApexDestruction/UDestructibleComponent/index.html](https://docs.unrealengine.com/en-US/API/Plugins/ApexDestruction/UDestructibleComponent/index.html)

If that are more errors, could you post your **.h** and **.cpp** file with **#includes**?

---

<div class="post-metadata">

**Author:** ![TheMaker\_AC](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TheMaker\_AC](https://forums.unrealengine.com/u/TheMaker_AC)\
**Post date:** [November 2, 2019, 9:47am UTC](https://forums.unrealengine.com/t/newbie-needing-help-plz-and-thanks/132873/3 "2019-11-02T09:47:53Z")

</div>

\*\*\*\*\*\* Header \*\*\*\*\*

```auto

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.

#pragma once
#include "Kismet/GameplayStatics.h"
#include <vector>
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Components/PostProcessComponent.h"
#include "Components/TimelineComponent.h"
#include "G_nadeProjectile.generated.h"

UCLASS(config=Game)
class AG_nadeProjectile : public AActor
{
    GENERATED_BODY()

    /** Sphere collision component */
    UPROPERTY(VisibleDefaultsOnly, Category=Projectile)
    class USphereComponent* CollisionComp;

    /** Projectile movement component */
    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Movement, meta = (AllowPrivateAccess = "true"))
    class UProjectileMovementComponent* ProjectileMovement;

    UPROPERTY(EditAnywhere, Category = "FX")
    class UParticleSystem* ExplosionParticies;

    UPROPERTY(EditAnywhere, Category = "SOUND_FX")
        class USoundCue* ExplosionSound;
    UPROPERTY(EditAnywhere, Category = "Projectile")
        float Radius = 500.f;

public:
    AG_nadeProjectile();

    virtual void BeginPlay() override;

    UFUNCTION()
    void OnDetonate();

    /** called when projectile hits something */
    UFUNCTION()
    void OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit);

    / **Returns CollisionComp subobject** /
    FORCEINLINE class USphereComponent* GetCollisionComp() const { return CollisionComp; }
    / **Returns ProjectileMovement subobject** /
    FORCEINLINE class UProjectileMovementComponent* GetProjectileMovement() const { return ProjectileMovement; }
};

```

\*\*\*\*\*\* CPP \*\*\*\*\*\*\*

```auto

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.

#include "G_nadeProjectile.h"
#include "GameFramework/ProjectileMovementComponent.h"
#include "Components/SphereComponent.h"
#include "DestructibleActor.h"
#include "DestructibleComponent.h"
#include "DrawDebugHelpers.h"

AG_nadeProjectile::AG_nadeProjectile()
{
    // Use a sphere as a simple collision representation
    CollisionComp = CreateDefaultSubobject<USphereComponent>(TEXT("SphereComp"));
    CollisionComp->InitSphereRadius(5.0f);
    CollisionComp->BodyInstance.SetCollisionProfileName("Projectile");
    CollisionComp->OnComponentHit.AddDynamic(this, &AG_nadeProjectile::OnHit); // set up a notification for when this component hits something blocking

    // Players can't walk on it
    CollisionComp->SetWalkableSlopeOverride(FWalkableSlopeOverride(WalkableSlope_Unwalkable, 0.f));
    CollisionComp->CanCharacterStepUpOn = ECB_No;

    // Set as root component
    RootComponent = CollisionComp;

    // Use a ProjectileMovementComponent to govern this projectile's movement
    ProjectileMovement = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("ProjectileComp"));
    ProjectileMovement->UpdatedComponent = CollisionComp;
    ProjectileMovement->InitialSpeed = 3000.f;
    ProjectileMovement->MaxSpeed = 3000.f;
    ProjectileMovement->bRotationFollowsVelocity = true;
    ProjectileMovement->bShouldBounce = true;

    // Die after 3 seconds by default
    InitialLifeSpan = 3.0f;
}

void AG_nadeProjectile::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
    // Only add impulse and destroy projectile if we hit a physics
    if ((OtherActor != NULL) && (OtherActor != this) && (OtherComp != NULL) && OtherComp->IsSimulatingPhysics())
    {
        OnDetonate();
    }
}

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

    FTimerHandle T_Handle;
    //GetWorld()->GetTimerManager().SetTimer(T_Handle, this, &AG_nadeProjectile::OnDetonate, 5.f, false);

}

void AG_nadeProjectile::OnDetonate()
{
    UParticleSystemComponent* Explosion = UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), ExplosionParticies, GetActorTransform());
    //Explosion->SetRelativeScale3D(FVector(4.f));
    //Explosion
    //UGameplayStatics::PlaySoundAtLocation(GetWorld(), ExplosionSound, GetActorLocation());
    //UGameplayStatics::PlaySoundAtLocation();

    TArray<FHitResult> HitActors;

    FVector StartTrace = GetActorLocation();
    FVector EndTrace = StartTrace;
    EndTrace.Z += 300.f;

    FCollisionShape CollisionShape;
    CollisionShape.ShapeType = ECollisionShape::Sphere;
    CollisionShape.SetSphere(Radius);

    if (GetWorld()->SweepMultiByChannel(HitActors, StartTrace, EndTrace, FQuat::FQuat(), ECC_WorldStatic, CollisionShape))
    {
        for (auto Actors = HitActors.CreateIterator(); Actors; Actors++)
        {
            UStaticMeshComponent* SM = Cast<UStaticMeshComponent>((*Actors).Actor->GetRootComponent());
            ADestructibleActor* DA = Cast<ADestructibleActor>((*Actors).GetActor());

            if (SM)
            {

                SM->ApplyRadialDamage(GetActorLocation(), 140, 10, ERadialImpulseFalloff::RIF_Linear, false);
            }
            else if(DA)
            {
                DA->GetDestructibleComponent()->ApplyRadialDamage(10.f, Actors->ImpactPoint, 500.f, 3000.f, false);
            }

        }

    }

    Destroy();

}

```

---

<div class="post-metadata">

**Author:** ![TheMaker\_AC](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TheMaker\_AC](https://forums.unrealengine.com/u/TheMaker_AC)\
**Post date:** [November 2, 2019, 12:13pm UTC](https://forums.unrealengine.com/t/newbie-needing-help-plz-and-thanks/132873/4 "2019-11-02T12:13:21Z")

</div>

Fixed it, i was to sleeply last night. You helped plus i was trying to apply a radialdamge to the SM instead of the AddRadialImpulse after that i re-run it and it worked thanks for the help **[SolidSk](https://forums.unrealengine.com/member/1364026-solidsk)**
