Simulating physical hit reactions using Control Rig

So I’ve been struggling with trying to get a realistic looking hit reaction to replicate. Straight animations rarely look great and typically you can use the Physical Animation Component or the Physics Control Component. But with multiplayer, getting the skeletal mesh to replicate is difficult when physics are involved. I tried a few plugins and they replicate movement nicely but not physics.

Im using control rig to make my character a bit more lively, and that replicates fine. I had a thought that I could make my character look like they have physical animations without doing physics calculations using control rig.

My initial thought is that I have a sphere trace around each body part. Each time an object hits the sphere trace, I invert the normal to move that body part in that direction at the velocity of the object that’s hitting. Does this seem viable? And does anyone have any resources on how this might be accomplished?

I was hoping to get some feedback before I start coding this and sink too much time into something that wont work in the long run, so if theres a better way to accomplish this, I’d be open to suggestions. Thanks in advance!

For anyone interested I’ve been messing with this the last few days and got it to work and it looks pretty similar to the Physical Animation Component, but since it’s running in the AnimBP it replicates nicely. I wouldn’t use it in anything large scale since it’s likely pretty network intensive but small scale stuff should be perfectly fine. Here’s a quick explanation:

In your AnimBP, you’ll create a vector variable for your Impact Normal and a bool variable for your Blocking Hit from your hit/overlap event. You’ll have to cast to your CharacterBP to get those values from your hit event and set the variables in your AnimBP equal to them. On your Animation Update event in the Event Graph of your AnimBP, you run a branch with the Blocking Hit variable as the condition. When true you set a vector variable within the AnimBP to the value of the Impact Normal. I then put a small delay (.05 seconds) and set the impact variable to 0 and the hit bool to false, this prevents the update event from continuously applying force and prevents the branch from continuously running the true condition. I may have to find a better way to do this since I could see it causing issues when lag or frame drops occur, but currently it provides enough time for the vector to be passed to control rig and seems to work nicely thus far.

In your Control Rig, create a Control Point. In your Anim Graph create a Control Rig node, click on it and click “Use Pin” for the control point that you created, which will allow you to dynamically effect the transform of that control point from outside of your Control Rig. Split the struct pin of the control point that you exposed, get your Impact Normal variable and plug it into the translation of the control point.

I’m already using a Spring Interpolate node to simulate the characters being a little floppy like they would with a Physical Animation Component, so I’ve refined my setup a bit. But if you haven’t, you can use a bone chain for each body part (spine_01 to spine_03 for example), do a forEach loop on that chain, plug the item of the forEach into the item of the Spring Interpolate node. This just applies a certain amount of strength and dampening for each item in that bone chain depending on how snappy or floppy you want that specific part to be. You can then get your Control Point, pull off the translation vector pin, multiply it by some amount to represent the magnitude of the hit, I started with 100, and plug it into the Torque pin of the Spring Interp. If you set everything up correctly you should see your character get slapped around when they get hit.

I just got this working a couple hours ago so I’ll be tweaking and improving it, but I’m really happy with the initial result. There are a couple things I plan on doing to make it look better. Instead of arbitrarily multiplying the Impact Normal by 100 for the hit magnitude within the Control Rig, I plan on doing it by weapon type. I’m already using an enum to determine what weapon hits, so I plan on doing a switch, multiplying the Impact Normal by some amount based on the weapon type (i.e. warhammer would be higher than a one-handed sword since it would apply more force), that way I can control how hard the character appears to get hit. I also plan on clamping the rotation of the control rig, so no matter how hard they get hit, they don’t spin around like some Looney Toons character, which they currently do. Here’s a good tutorial on how to do that if anyone’s interested: https://youtu.be/SApROV3FY28?si=5rkLdwrx1lbOTkW0

If anyone is interested enough, I can provide a quick video of what this looks like in action and a few screenshots of my setup. Hopefully this helps.

Looking to try this approach myself, will be interested in a video :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.