Adding a force to Actor

Im new to the c++ side of unreal and wanted to know how to add a force or impulse to my actors, when they spawn.

I created a BP for my object and added the sphere static mesh to my BP.
In some examples i read, they got the UStaticMeshComponent from the AActor and then did AddForce

So i tried:

    StaticMesh = Cast<UStaticMeshComponent>(this);
    check(StaticMesh != NULL);
    StaticMesh->AddForce(ForceToAdd * StaticMesh->GetMass());

and added that into my BeginOnPlay() method.

I originally had it in the constructor but i read that you shouldnt do that.
When i build there are no errors, but the game crashes on the check.
In the debug it say that StaticMesh is Null, so im wondering if the cast im using is wrong. How would i go about getting the UStaticMeshComponent or is there another way to apply a force to my object.

Thank you!

I got the Ustaticmesh component by following this answer

    TArray<UStaticMeshComponent*> Comps;

     GetComponents(Comps);
     if(Comps.Num() > 0)
     {
             UStaticMeshComponent* FoundComp = Comps[0];
             //do stuff with FoundComp
     }

I generally use “AddImpulseAtLocation” using the following code:

// GetMesh() will find the mesh
// GetVelocity will find the current velocity of the actor, in your case it will be 0
// 300.0f will make the impulse stronger
// Get Actor Location is a vector that returns the world location
GetMesh()->AddImpulseAtLocation(GetVelocity() * 300.0f, GetActorLocation());

Think of the constructor like this: Items are constructed, even before you press play, or rather, you see the values that you added into the constructor when you look at them in the editor. Default values are passed in that you can modify later. If you attempt to add impulse here, it will absolutely crash.

You have another function called BeginPlay that runs the second you actually start the game.