human
I'm currently making a game in Unreal engine and I want my characters to physically react to being hit without animating each hit. Is there a way to have animations on an actor while simulating physics at the same time?
gpt
After analyzing your objective, I recommend implementing a physics-based system that applies force to your characters upon being hit. This can be achieved using the AddForce function in Unreal Engine.

Here is a sample code snippet that demonstrates how to implement physics simulation on actors in Unreal Engine:

//in your character class

UFUNCTION() void OnHit(AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit) { //apply force in the direction of the hit FVector ForceDirection = -Hit.ImpactNormal; ForceDirection.Normalize(); MyMeshComponent->AddForce(ForceDirection * Hit.Impulse, NAME_None, true); }

In the above code snippet, the OnHit function is triggered when the character is hit. The AddForce function is then called to apply force in the direction of the hit, causing the character to physically react to being hit.

By using this approach, you can create a more realistic and dynamic game without the need for animating each hit. I hope this helps you achieve your objective!