Download

Does add force work?

I can find the name of the object I hit. I am using the c++ fps demo, when the projectile hits an object it console logs the name. It gives me a message saying it is iterating through the primitive components type of the actor with getcomponents. Then addforce does nothing.

I also tried to addforce to the HitComp, OtherComp in the Character.cpp (found in the default c++ fps template in unreal 4.22.3)

I’m not sure how to do this, I just want to move the object I hit

Sometimes i use add impulse at location . Force works but u need to use a lot and in the correct direction. Xyz i think my force settings were at z 55000 in order to make a rigid character jump into the air after grenade blast. Give or take a zero

TArray<UStaticMeshComponent*> Components;
OtherActor->GetComponents<UStaticMeshComponent>(Components);
for (int32 i = 0; i < Components.Num(); i++)
{
UStaticMeshComponent* StaticMeshComponent = Components*;
FVector MeshUpVect = StaticMeshComponent->GetUpVector();
float ForceStrength = 100000.0f;
StaticMeshComponent->AddForce(MeshUpVect * StaticMeshComponent->GetMass() * ForceStrength);
}