I have a problem with physics, but not the usual problem. My problem is as follows.
I am trying to attach extra skeletal meshes to my character (tools, items, those kind of things). One of those, a lantarn, has various physics bodies set to “simulating” in its corresponding PHAT file.
The problem is, while they are set correctly, they don’t have any effect whatsoever outside of PHAT. If I equip the tool on my character, the tool just looks static.
In the above picture it’s rather hard to see, but the lantarn is always pointing downwards, no matter what the position of the hand holding it is. I reckon it’s a limitation of simulating physics within PHAT, but if that is the case, how can I go about this?
What I want to do is attach only the tip of the lantarn to the socket in the hand. With the tip attached, the movement of the rest of the lantarn should be calculated by physics. How do I go about this?
This option is used via the blueprint, but perhaps you want to enable it permanently on a world placed object, it will have a physics section on the mesh object.
Perhaps you need to tell it which bone to start the physics on.
Since I already tried the first before asking here (with less than desirable results) I have tried your second suggestion. While there is now motion on the lantern, it’s weird motion (as in, it doesn’t give the impression of inheriting any motion from the main character; it just swings back and forth without losing any speed). It also gives me a warning “Make sure collision is enabled or the root bone has body in PhysicsAsset.”
I tried giving it a proper collision preset but that didn’t seem to solve the problem. The root bone already has a body in the physics asset, as you can see in the initial post.
Edit: I should mention I am doing this directly in the skeletal mesh component class.
Make sure collision is enabled or the root bone has body in PhysicsAsset.
This is an interesting tip, Do you have a collision body assigned to the root bone for this skeleton in the physics asset?
I would opt to hand create the physics asset and yes making sure the root bone is where it all starts.
So I am not sure where the forces applied are generated yet, lets perhaps get some DrawDebugX on some of the vectors coming from the physics system during operation to help you visualize what it is trying to do.
Next would be to remove it from the hand, attach it to a static object in the scene and apply hits to it with the mouse or something where you are applying force manually.
Gee, I did a poor job of reading the portion regarding the root body, Have you tried messing with the shape of the root body more? Where is the constraint for it?
Yeah, the root is the out of place sphere at the handle top. I haven’t really messed with it yet, I only replaced the capsule with a sphere. There are 3 bones in total; the root, the lantern and a bone to connect the two. Technically, I would like to have those 2 bones swing under the root bone, but if necessary, I could weld the two bones below the root and just make it one.
How are the constraint’s configured? I suggest you make sure each bone has one and that you fiddle with them, For this behavior my recommendation of attaching it to a static actor and using a mouse to hit it and watch its response based on how you have the mouse force configured is a good way to debug it and get a feel for the system in general.
As you suggested, I added the lantern to the scene (but instead of the mouse, I used hit events for impulse) and it seems that in the scene, it is working (netting me a nice little physics object I can use for decoration).
However, having the main character hold the lantern still gives problems. While the animation is now better and actually responds to the velocity of the main character, sometimes the lantern gets stuck on one of the axis rotation limits making me have to move the character to have the lantern start swinging again. I am also still getting that “Warning Invalid Bodies : Make sure collision is enabled or root bone has body in PhysicsAsset.” warning.
I solved the remaining problems. Turns out I made a mistake in which bone to use for the “Set All Bodies Below simulate physics.” I was under the impression that it start simulation on all bones below it, but I have a suspicion that it actually starts at the bone you enter as the bone name.
Since I had the root bone in there at first, it started simulating my entire mesh. When I put in the bone right below the root bone, it did exactly what I wanted it to.
If you can make your reply into the answer to this question, we can close this topic. Thanks for your help!