Im using the default driving game with the sedan, ive made an ai character using these tutorials ( - YouTube ) Now Id like the ai to go ragdoll when struck by the sedan but im not sure how to do this. Any help would be great thanks!
Hello,
I have created a simple setup to get a pawn to ragdoll when it is hit by the default sedan. The first thing I did was to create a Pawn Blueprint that was going to be the base for my character. I then added a Scene Component, Capsule Component, and Skeletal Mesh Component. Also, it is important that if you want your Pawn to be able to move that you add a Floating Pawn Movement Component. I set the collision of both my Capsule and Pawn to the Pawn preset.
This is what my Components panel looks like inside of my Pawn blueprint.
After I completed the basic setup, I began working on the logic. I wanted the force to be applied and the ragdoll to occur when the vehicle hit the Pawn’s capsule component, so I used an OnComponentHit event. You can see the setup here:
The ForceFromHit variable is optional, but I figured it would be nice to apply force to the Pawn based on how fast the vehicle was going. The reason I divided the Engine Rotation Speed was because the initial return value is quite high, and applied too much force for what I was looking for. I chose to divide by 3, but you can customize that number to your liking. After setting the Force From Hit variable, I Set Simulate Physics on the skeletal mesh component, and then applied the radial impulse which will cause the Pawn to fly backwards when it is hit.
Finally, before this setup will work properly, it is imperative that you drag an instance of your Pawn into the level, and then set the Physics Asset Override option to use the Physics Asset that comes with the default character mannequin. If you do not do this, the skeletal mesh will not be able to simulate physics, and will not ragdoll. This option can be found under the Physics tab of the details panel when you have your Skeletal Mesh component selected.
This setup should allow you to get the results that you’re looking for, but feel free to ask any further questions or let me know if you need clarification on any of the steps.
Also, forgot to mention that after the Add Radial Impulse node, you’ll need to add a Destroy Component node and destroy the Capsule Collision. If not, you will still be running into it and applying force after the character is forced away from the vehicle.
The pages are private or don’t exist anymore. Could you post a new link?