• Getting Ragdoll bone vectors/angles
    26 replies, posted
Hi guys, Does anyone know how to find the location of a ragdoll's bone vectors/angles? I'm editing a SWEP and can't seem to find a way to locate these. Cheers
Entity:GetBonePosition( 1 ) It returns two values, you'd use them like this: [code]local vPos, aAng = Entity:GetBonePosition( 1 );[/code]
Thanks! But how? like do I put that in console? do I make a LUA file?
No you'd put it in your SWEP.
Hi, Tried to do this into a swep but didn't work, could someone assist?
Sure we can Show us what you tried
[CODE]AddCSLuaFile() SWEP.Base = "weapon_base" SWEP.PrintName = "fire_admin_tool" SWEP.Slot = 1 SWEP.SlotPos = 3 SWEP.DrawAmmo = false SWEP.DrawCrosshair = true SWEP.ViewModel = "models/weapons/v_pistol.mdl" SWEP.WorldModel = "models/weapons/w_pistol.mdl" SWEP.ReloadSound = "Weapon_357.Reload" SWEP.HoldType = "pistol" -- Other settings SWEP.Weight = 1 SWEP.AutoSwitchTo = false SWEP.Spawnable = true -- Weapon info SWEP.Author = "" SWEP.Contact = "" SWEP.Purpose = "For admin use with DarkRP Fire System (Coder Hire)" SWEP.Instructions = "Left click: Start Fire, Right click: Remove ALL Fires" -- Primary fire settings SWEP.Primary.Sound = "Weapon_StunStick.Swing" SWEP.Primary.Automatic = 1 SWEP.Primary.Ammo = "Pistol" SWEP.Category = "Weapons" function SWEP:Initialize() end function SWEP:PrimaryAttack() if ( !self:CanPrimaryAttack() ) then return end Entity:GetBonePosition( 1 ) end[/CODE]
[QUOTE=nzkfc;43675872]Thanks! But how? like do I put that in console? do I make a LUA file?[/QUOTE] No offense but if you don't even know where to insert code or how to make an Lua file, you should at least take a few weeks break and actually learn Lua instead of diving into it and causing yourself frustration and making stupid/dumb/pointless questions that even a beginner doesn't have to ask. Trust me, I pulled this kind of shit on another programming language. Actually learning the language helps me understand a lot on what the fuck I'm doing. [editline]21st February 2014[/editline] And AddCSLuaFile() should at least contain a string pointing to a file name
[QUOTE=Swog;43992607]No offense but... [editline]21st February 2014[/editline] And AddCSLuaFile() should at least contain a string pointing to a file name[/QUOTE] When AddCSLuaFile( ) is empty, ie without arguments, it will send the file that it is in to the client.
You don't have to rate someone dumb because they didn't know something, I've talked to a ton of a scripters that wasn't even aware that when it had to arguments it at the file it was in to the client.
[QUOTE=Swog;43992607]No offense but if you don't even know where to insert code or how to make an Lua file, you should at least take a few weeks break and actually learn Lua instead of diving into it and causing yourself frustration and making stupid/dumb/pointless questions that even a beginner doesn't have to ask. Trust me, I pulled this kind of shit on another programming language. Actually learning the language helps me understand a lot on what the fuck I'm doing. [editline]21st February 2014[/editline] And AddCSLuaFile() should at least contain a string pointing to a file name[/QUOTE] Thanks for your response, albiet typical. I don't have time to learn LUA nor do I want to learn it, I simply have one small issue "getting rag doll bone locations" for something else i'm working on. As the dev of the original addon was unable to confirm how to do this, I come here instead. Also if 3 major devs within the gmod/darkrp community can't work it out, how can I work it out from just learning a bit of LUA. I suggest you turn on your uber skill god mode lua skills and post up the full working SWEP/Solution then huh?
"Major devs" I laughed. If they can't use the wiki and know about this function, they're far from being developers at all! You can learn it using the language really. You won't ask "where does it go?" It's like someone giving you a complete class in C#, only to ask where you put it. "In a .txt? In ...?" [editline]21st February 2014[/editline] As someone said, the function is ENTITY/GetBonePosition which returns the position and angle. [editline]21st February 2014[/editline] Judging from what you did, you don't know jack shit about lua, so even knowing about this function, you can't and won't be able to implement it properly. You're just wasting your time diving with 0 knowledge in programming or coding, into something that requires a decent knowledge of it.
[QUOTE=Acecool;43995089]When AddCSLuaFile( ) is empty, ie without arguments, it will send the file that it is in to the client.[/QUOTE] I'm completely clueless and did not see this. Thanks, though.
[QUOTE=Kuro Light;43998128]"Major devs" I laughed. If they can't use the wiki and know about this function, they're far from being developers at all! You can learn it using the language really. You won't ask "where does it go?" It's like someone giving you a complete class in C#, only to ask where you put it. "In a .txt? In ...?" [editline]21st February 2014[/editline] As someone said, the function is ENTITY/GetBonePosition which returns the position and angle. [editline]21st February 2014[/editline] Judging from what you did, you don't know jack shit about lua, so even knowing about this function, you can't and won't be able to implement it properly. You're just wasting your time diving with 0 knowledge in programming or coding, into something that requires a decent knowledge of it.[/QUOTE] Hence my OP............ i'm simply trying to get the angle/vec of ragdoll bones and the DarkRP author told me to add a few lines of code into a SWEP........... So I came here to ask for help. Look this is a forum, if you can help then please do post a solution or direct me to a place I can read up on this (if applicable which you have pointed out isn't) otherwise don't post. The world needs less rubberneckers in forums, dropping in to say "LOL IDIOT" then going out.
?????? We posted a solution. It's your fault if you're too dumb to use it.
[QUOTE=Kuro Light;44024956]?????? We posted a solution. It's your fault if you're too dumb to use it.[/QUOTE] Nice.... call someone dumb when they simply don't know something. I'm glad when you started coding you got everything you ever needed to know from thin air mate.... Posting a line of code and calling that a solution is like asking a mechanic "why does my car not start" and them telling you "because a hose is missing" Great.... now how can I make it start... what part, how do I remove the old one/put new one on. I didn't ask for the code, I asked how can I capture them. Just piss off if you don't want to help. EDIT: wow you even do it yourself......... [url]http://facepunch.com/showthread.php?t=1296406[/url] see if people were not dicks online, the world would be moving forward in all aspects of life.
Mate the first post was literally the be-all end-all answer to your question. You asked how to find the bone position and angle for a bone and he posted the code. Nobody knows what more you want, and the swep code you posted doesnt even hint at anything other than that you took a template swep and pasted the function the first post gave you. [editline]24th February 2014[/editline] Like a better analogy would be the customer saying "I need a 10cm long Phillips head screw", and when the mechanic gives the customer that piece, the customer says "awesome! do I put it in the glove compartment? wedge it in the steering wheel?". The mechanic then asks why you ordered the screw and the customer shows the mechanic his TV, which has the screw nailed into it, and demands to know why the mechanic is so useless.
[QUOTE=nzkfc;44025757]Nice.... call someone dumb when they simply don't know something. I'm glad when you started coding you got everything you ever needed to know from thin air mate.... [/QUOTE] You're dumb since they spoon-fed you what you needed to do and told you what to do but you refused to do it and wanted somebody to hold your hand the whole way through. There's also a massive wiki (two of them actually) waiting to be read for about two minutes so you'd know exactly what to do. It's okay to be ignorant, but not when you force yourself to be ignorant-- that's called being dumb. [quote]Posting a line of code and calling that a solution is like asking a mechanic "why does my car not start" and them telling you "because a hose is missing"[/quote] Not really, you're trying to give extra functionality rather than debug, so it's more like them giving you a computer fan and expecting you to figure out how to shove it into your computer. [quote]EDIT: wow you even do it yourself......... [url]http://facepunch.com/showthread.php?t=1296406[/url][/quote] He asked for help, yeah, everybody does. The difference is he wasn't stupid nor a dick about it. [quote]see if people were not dicks online, the world would be moving forward in all aspects of life. [/quote] The funniest thing about this, is that if you weren't an complete dick about all of this, you would have been done and moved forwards already. But hey, if you're a self-satisfied over nothing, self-righteous shit-stain nothing we do is going to help. You're chasing a bus that has long departed, the answer was already given and you're still asking for more. Fix your attitude then maybe others will fix your shit (even though they already did). Better yet, stop posting and just piss off if you don't want to accept the help they've already given you.
I asked for help when everything I tried didn't work, asking if other fellow coders figured out a solution to it. Seems like there weren't an I stopped posting. It's different from asking a question in a topic you have 0 knowledge about. So I don't get why you're crying and saying I'm a hypocrite. [editline]24th February 2014[/editline] [QUOTE=Disseminate;44026023]Mate the first post was literally the be-all end-all answer to your question. You asked how to find the bone position and angle for a bone and he posted the code. Nobody knows what more you want, and the swep code you posted doesnt even hint at anything other than that you took a template swep and pasted the function the first post gave you. [editline]24th February 2014[/editline] Like a better analogy would be the customer saying "I need a 10cm long Phillips head screw", and when the mechanic gives the customer that piece, the customer says "awesome! do I put it in the glove compartment? wedge it in the steering wheel?". The mechanic then asks why you ordered the screw and the customer shows the mechanic his TV, which has the screw nailed into it, and demands to know why the mechanic is so useless.[/QUOTE] That analogy was golden.
Apologies, I do know my replies are "shit" I just find after going down various roads for help and getting the same (to someone who doesn't know any code) what feels like 10% of the solution hard. Noting everwhere else I get help for various things you get not only the answer, but a bit of additional suggestion in how one would use it. E.g the code is this, so when you go in game, point at XYZ and type that into console or however it's used. It eats at me because when people need help on something I know how to do, I ensure the person not only knows how to do it but to show them examples of what they would do. Maybe I'm just reading replies in a negative tone and taking it as unhelpful. All I was wanting to know, is if I setup a rag doll standing on a map in a certain position, how do you capture their bone vectors and angles, not only the code for this but how would one use this? Type in console or whatever, so that I can list them out like the below example: local rag1Pos = { Vector( 0, 0, 0 ), Vector( 0, 0, 0 ), Vector( 0, 0, 0 ),
Here's a start. [lua] local tbl = {}; for i = 1, Entity:GetBoneCount(), 1 do tbl[i] = { Entity:GetBonePosition( i ) }; end -- To get pos of the 2nd bone: print( tbl[2][1] ); -- To get angle of the 2nd bone: print( tbl[2][2] ); [/lua]
[QUOTE=Johnny Guitar;43995171]You don't have to rate someone dumb because they didn't know something, I've talked to a ton of a scripters that wasn't even aware that when it had to arguments it at the file it was in to the client.[/QUOTE] You're absolutely right, I changed it to disagree. Thanks! [editline]25th February 2014[/editline] [QUOTE=nzkfc;44036797]Apologies, I do know my replies are "shit" I just find after going down various roads for help and getting the same (to someone who doesn't know any code) what feels like 10% of the solution hard. Noting everwhere else I get help for various things you get not only the answer, but a bit of additional suggestion in how one would use it. E.g the code is this, so when you go in game, point at XYZ and type that into console or however it's used. It eats at me because when people need help on something I know how to do, I ensure the person not only knows how to do it but to show them examples of what they would do. Maybe I'm just reading replies in a negative tone and taking it as unhelpful. All I was wanting to know, is if I setup a rag doll standing on a map in a certain position, how do you capture their bone vectors and angles, not only the code for this but how would one use this? Type in console or whatever, so that I can list them out like the below example: local rag1Pos = { Vector( 0, 0, 0 ), Vector( 0, 0, 0 ), Vector( 0, 0, 0 ),[/QUOTE] Here's a helper function for grabbing a table worth of information on bones. [lua]// // Returns an organized table with bone-data for the entity - Josh 'Acecool' Moser // function ENTITY:GetBones( ) local _bones = { }; for i = 0, self:GetBoneCount( ) - 1 do local _pos, _ang = self:GetBonePosition( i ); _bones[ i ] = { name = self:GetBoneName( i ); pos = _pos; ang = _ang; parent = self:GetBoneParent( i ); matrix = self:GetBoneMatrix( i ); controller = self:GetBoneController( i ); }; end return _bones; end[/lua] If you look at TTT, it shows how they spawn a ragdoll in place of a person when they die and position the ragdoll in the players exact pose [lua] -- position the bones local num = rag:GetPhysicsObjectCount()-1 local v = ply:GetVelocity() -- bullets have a lot of force, which feels better when shooting props, -- but makes bodies fly, so dampen that here if dmginfo:IsDamageType(DMG_BULLET) or dmginfo:IsDamageType(DMG_SLASH) then v = v / 5 end for i=0, num do local bone = rag:GetPhysicsObjectNum(i) if IsValid(bone) then local bp, ba = ply:GetBonePosition(rag:TranslatePhysBoneToBone(i)) if bp and ba then bone:SetPos(bp) bone:SetAngles(ba) end -- not sure if this will work: bone:SetVelocity(v) end end[/lua]
Thanks Acecool, Now how would I use that first block of code? Do I put it into a lua file somewhere in autorun or similar? Depending on the above answer I assume the next could be and how would one use that file, do I simply spawn a rag doll and check console, or run a command to print?
It's mainly for dev-work. On the client you could call [lua]local _bones = LocalPlayer( ):GetBones( ); [/lua] and it will generate a table with bone info. then just use: [lua]for k, v in pairs( _bones ) do if ( v.name == "SomeBoneName" ) then LocalPlayer( ):ManipulateBoneScale( k, scale ); end end[/lua] etc. You can use the pos, ang to change their values based on the location at the time of building the table, get the parent of bone, the controller etc.
Thanks again, But this is my point, you are telling me to use the above and I don't know how specifcially? Do I type that in console? put it in a lua file? make a SWEP with it? That's the piece i'm scratching my head at.....
It would be in a lua file, you'd need to ENTITY = FindMetaTable( "Entity" ); before the function, then it can be called on any entity if you want to use the GetBones function. What exactly are you trying to do in your swep, that may be the better question to ask... You say you're editing a SWEP, but what do you want to accomplish by finding these bones? one of your replies states you want to capture the bone positions and angles. ENTITY:GetBones( ) does this by putting it into a table for you to use later. The TTT code I pasted uses this in a real scenario where on PlayerDeath, a ragdoll is spawned where the player is, and the player bone positions and angles are transferred to the ragdoll so that the player disappears from view, and the Ragdoll is the "person" and falls from where the person was just standing to make it appear seemless. You do need to make a Lua file for these things to work. If you want everyone to see the changes, you need to do it server-side.
Ahah! That's what I was looking for! Perfect it's working. Cheers!
Sorry, you need to Log In to post a reply to this thread.