tipforeveryone Posted February 22, 2016 Share Posted February 22, 2016 After 1 week learning LUA Script in Leadweeks, with asistance from our mighty members (macklebee, Josh, Brutile), I have created a test ragdoll and a gun to shoot it. Ragdoll's limbs are dismemberable too. These are videos about my work (this one has a better quality) I feel so excited now. I want to go further... I mean How can I "attach" this ragdoll skeleton to my character Mesh? I used Blender Export Addon for Leadwerks, after that I only got a .mdl file with out any bones in it. I created bones for my character in blender. I noticed that bones are still remain with exported FBX file but I don't know how to use those bones Can anyone give me some suggestions about my question ? Just show me the right way. I will follow hehe. Thank you guys ========================================== (Edited in 160222) ========================================== This part is for members who want to refer my ragdoll code. I know these codes are not perfect and surely need more development. You are free to adjust my code. If you find out any better method to improve it, please reply in this topic. I know I am still new with LUA Script and game programming. Here is the instructions: Create a new Map then a Box for a ground. Create a Pivot, place it right on top of the ground box, name it "Ragdoll spawner" or whatever you like. Attach "RagdollChest.lua" to this Pivot. You can change any parameters of Ragdoll, everything will be auto adjusted to produce a desired ragdoll form in your map's scene. Create a Camera then attach "CustomFPSPlayer.lua" to it, Drag above "Ragdoll spawner" into "Target ragdoll" and choose "fire sound" in Script tab. You should change the default weapon model (around lines 46 - 48) That is all !! Press F5 and have fun. Control: Left Mouse = Shoot Right Mouse = Iron Sight Middle Mouse = Reset Ragdoll ADSW = Movement control X = FreeBone Style1 C = FreeBone Style2 (default for bullet impact on ragdoll) RagdollChest.lua CustomFPSPlayer.lua 2 Quote Link to comment Share on other sites More sharing options...
nick.ace Posted February 22, 2016 Share Posted February 22, 2016 How did you get the ragdoll physics to work so well? I remember spending hours only to find out that the joints are super-elastic when I tried to do it. Attaching isn't too difficult. All you do is get the model's children and set the position of each bone to the ragdoll's limbs (you don't have to parent all the bones though). One issue I remember having though is that sometimes the model will disappear because it's bounding box kind of gets messed. I don't remember how to fix that part, but one thing that can help a little is to reposition the mesh to the torso of the ragdoll and manipulate the bones there. 2 Quote Link to comment Share on other sites More sharing options...
tipforeveryone Posted February 22, 2016 Author Share Posted February 22, 2016 How did you get the ragdoll physics to work so well? I remember spending hours only to find out that the joints are super-elastic when I tried to do it. Attaching isn't too difficult. All you do is get the model's children and set the position of each bone to the ragdoll's limbs (you don't have to parent all the bones though). One issue I remember having though is that sometimes the model will disappear because it's bounding box kind of gets messed. I don't remember how to fix that part, but one thing that can help a little is to reposition the mesh to the torso of the ragdoll and manipulate the bones there. Thanks for your reply, nick.ace You said exactly, those bones connection is so elastic. I spent a whole day to find out that too, It seems to be no solution, then I decided to live with this. Created bones by Joint:Ball and Joint:Hinge will be ok if I leave it "free", I mean no picking or interaction after dropping all bones for free falling, set collision type of bones to "Debris". Otherwise, they will be pulled out like hell... All of my ragdoll's bones were created by code (Model:Box()). You mean I need to cut my model's body parts into pieces (sperated legs, arms, hands, head, torso etc) then attach each of them to corresponding bone ? 1 Quote Link to comment Share on other sites More sharing options...
Nexerade Posted February 22, 2016 Share Posted February 22, 2016 Mmm... will you share the code with us?.. Quote I am not silly. My english is just not really great. T_T But I'm learning! Link to comment Share on other sites More sharing options...
drarem Posted February 22, 2016 Share Posted February 22, 2016 I wonder if you can go through each child joint on a model and change it to that type, is that even possible? Quote Link to comment Share on other sites More sharing options...
Ma-Shell Posted February 22, 2016 Share Posted February 22, 2016 (edited) You said exactly, those bones connection is so elastic. I spent a whole day to find out that too, It seems to be no solution, then I decided to live with this. You don't need to live with this It is possible to directly access the NewtonDynamics-Functions like so: Joint* j; j = (...) NewtonJointSetStiffness(((NewtonDynamicsJoint*)j)->newtonjoint, 0.42); will set the stiffness of the joint j to 0.42. Of course you will have to make j point to the joint you created previously, before calling the function. EDIT: Oops, just noticed, you are probably using LUA, as you wrote things like "Model:Box()". No idea, whether you can do something like this in LUA. Edited February 22, 2016 by Ma-Shell 1 Quote Link to comment Share on other sites More sharing options...
tipforeveryone Posted February 22, 2016 Author Share Posted February 22, 2016 Mmm... will you share the code with us?.. Yes of course, I edited my topic with a small instruction part Feel free to download my .lua files I wonder if you can go through each child joint on a model and change it to that type, is that even possible? I will give it a try Oops, just noticed, you are probably using LUA, as you wrote things like "Model:Box()". No idea, whether you can do something like this in LUA. Thanks for your reply! It is ok I have lived with that 1 weeks anyway, hehe. Quote Link to comment Share on other sites More sharing options...
nick.ace Posted February 23, 2016 Share Posted February 23, 2016 Sorry, I forgot you are doing dismemberment. If you were just doing a normal ragdoll, I'd say you could keep the mesh as one whole. If you are dismemberment, then I don't really know the best way. Still waiting on that Lua support though. Quote Link to comment Share on other sites More sharing options...
tipforeveryone Posted February 23, 2016 Author Share Posted February 23, 2016 Sorry, I forgot you are doing dismemberment. If you were just doing a normal ragdoll, I'd say you could keep the mesh as one whole. If you are dismemberment, then I don't really know the best way. Still waiting on that Lua support though. Yes, I want a violent gameplay muahahha... Then I think I will find out how to do that But, can you give me more instruction about attaching my bones to mesh? maybe a function in API Library which I did not notice or a small step by step tutorial, links, anything... Thank you Quote Link to comment Share on other sites More sharing options...
nick.ace Posted February 23, 2016 Share Posted February 23, 2016 Yeah sure. You need to call FindChild() from your mesh, and that function takes in a string where you can specify a bone. This bone is an entity, so you can call SetPosition() and SetRotation() on it to the position and rotation of the joints of the ragdoll (GetPosition() and GetRotation()). Make sure you set the global flag to true though. You should be all set with this, but it'll end up being a lot of copy/pasting code since you have to do this with each joint. 1 Quote Link to comment Share on other sites More sharing options...
tipforeveryone Posted February 23, 2016 Author Share Posted February 23, 2016 Yeah sure. You need to call FindChild() from your mesh, and that function takes in a string where you can specify a bone. This bone is an entity, so you can call SetPosition() and SetRotation() on it to the position and rotation of the joints of the ragdoll (GetPosition() and GetRotation()). Make sure you set the global flag to true though. You should be all set with this, but it'll end up being a lot of copy/pasting code since you have to do this with each joint. I feel a bit confused now. It will be nice to use FindChild() but I have some problems with my exported mesh. It was made in Blender and exported by "Exporter for Leadwerks" addon to .mdl and .mat files. I open Leadwerks Model editor and find out that all of my character's bones were removed. So here are my questions 1. If I use Addon to export from Blender, is it possible to attach my ragdoll bone to the exported mesh (with no bones from Blender) ? 2. If I export to .FBX, yes, all of original bones are still there, showed in Leadwerks's model editor, do I need to "recode" them? And my model's skinning is still operational ? Quote Link to comment Share on other sites More sharing options...
nick.ace Posted February 24, 2016 Share Posted February 24, 2016 Yes, you would need an animated (or at the very least rigged) mesh. I static mesh isn't going to be very useful for this. You don't need to recode anything. You just need to call FindChild() to get a reference of them in code and set the position and rotation of each of them to the corresponding ragdoll you made in the video. The model will still be allowed to animate, you just need to not set set the position or rotation while it's doing this. 1 Quote Link to comment Share on other sites More sharing options...
tipforeveryone Posted February 28, 2016 Author Share Posted February 28, 2016 Yes, you would need an animated (or at the very least rigged) mesh. I static mesh isn't going to be very useful for this. You don't need to recode anything. You just need to call FindChild() to get a reference of them in code and set the position and rotation of each of them to the corresponding ragdoll you made in the video. The model will still be allowed to animate, you just need to not set set the position or rotation while it's doing this. 1 week passed and finally, I have done this "Bones and Mesh" Here it is, the combination of mesh's original bones from blender and my own bones system, they work with eachother perfectly. I find out how to dismember character's limbs too. WIP thank you so much nick.ace!! Quote Link to comment Share on other sites More sharing options...
chrisb Posted April 27, 2016 Share Posted April 27, 2016 I made the ragdoll explode Quote Message me if you want help creating a game Link to comment Share on other sites More sharing options...
chrisb Posted May 7, 2016 Share Posted May 7, 2016 I made a few changes and also made the model explode 1 Quote Message me if you want help creating a game Link to comment Share on other sites More sharing options...
Thirsty Panther Posted May 7, 2016 Share Posted May 7, 2016 Video ? 1 Quote Link to comment Share on other sites More sharing options...
chrisb Posted May 14, 2016 Share Posted May 14, 2016 Video ? easiest way to record? Try the attacjed files, h is for explode RagdollChest.lua CustomFPSPlayer.lua Quote Message me if you want help creating a game Link to comment Share on other sites More sharing options...
chrisb Posted May 14, 2016 Share Posted May 14, 2016 hmmm, Kept saying the post had failed RagdollChest.lua CustomFPSPlayer.lua 1 Quote Message me if you want help creating a game Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.