Download

Add Force / Impulse Not responding.

I’ve got two different projects both of them have projectiles that come out of a gun. I’ve tried via code as well as BP including even copy and pasting the BP Nodes between projects, and In the first project projectiles come out of the gun as expected move in the correct direction etc. In the second projects they just fall from the gun with no velocity? I’ve checked to see if any of the physics settings are different, and can’t see anything different. Any Ideas?



AActor* bullet = GetWorld()->SpawnActor(mBullet, spawnLocation, rotation); 
	
	TArray<UStaticMeshComponent*> component; 
	bullet->GetComponents(component); 
	if (component.Num() > 0)
	{	
		FVector force = (component[0]->GetForwardVector() * 5000.0f);
		component[0]->AddImpulse(force);
	} 


45a2a3837bb7c9a9f3e8753456261318e16134fe.png

Thanks,

Rich.

Update: If I AddImpulse() on every frame, instead of just BeginPlay() The bullet speeds up over time. AddForce() is similar when I provide a higher multiplier, (which seems accurate as to what the functions do) but the bullet stays the same speed even though I’m adding force each frame.

Update 2:

Alright so I’m not sure if this is normal or not, I would say no since in my other projects the projectile worked fine, however if I set a flag (ForceHasApplied = false) and in the first tick function



if(!ForceHasApplied)
{
    staticMesh->AddImpulse(staticMesh->GetForwardVector() * 50)
    ForceHasApplied = true;
}

Then it functions as expected.

Any idea’s why it works fine in the first tick, but not in BeginPlay(), and apparently only in this project?