• SetVelocity for ent / physics object issues
    8 replies, posted
I have made a ragdoll on death, the only issue is the :SetVelocity() doesnt work directly on the entity, so I tried using :GetPhysicsObject():SetVelocity() which worked, but it would put errors in the server console saying: [ERROR] lua/weapons/weapon_defib.lua:181: Tried to use a NULL physics object!   1. AddVelocity - [C]:-1    2. v - lua/weapons/weapon_defib.lua:181     3. unknown - lua/includes/modules/hook.lua:84 So, I put I replaced it with: if IsValid(deathRagdoll:GetPhysicsObject()) then deathRagdoll:GetPhysicsObject():SetVelocity(victim:GetVelocity()) end Which stopped it working all together. Is there a way I can get the ent to have the same velocity as the player when it spawns? Also when it was working, I could no longer interact with the ent (as in the SWEP I am using couldn't find it via eyetrace) and it couldn't be physgunned, though this may be due to the error. Any help is appreciated!
you wanna do for i = 0,deathRagdoll:GetPhyiscsObjectCount() - 1 do local phys = deathRagdoll:GetPhysicsObjectNum(i) phys:SetVelocity(victim:GetVeocity() end I believe
Tried it but still didn't work, the model went back to t-posing and falling down without any velocity, the only thing that seems to get it working is still: deathRagdoll:GetPhysicsObject():SetVelocity(victim:GetVelocity()) But still causes the same error, saying it tried to use a NULL entity, despite achieving the goal. I tried adding: if phys != NULL then phys:SetVelocity(victim:GetVelocity()) end But still, no error and not working at all. Thanks for the suggestion though, if you have any more thoughts let me know as I'm still stuck.
if not IsValid(deathRagdoll) then return end local phys = deathRagdoll:GetPhysicsObject() if IsValid(phys) and IsValid(victim) then phys:SetVelocity(victim:GetVelocity()) end
Thanks for the suggestion but still not working, once again no errors and its just T-Posing the model still, no velocity.
bump
Everything works for me accept the velocity part (I didn't copy paste the code. Just used my own version with prop_ragdoll. But it's still similar). What function are you using? Also, could you not used Player:CreateRagdoll() or is this just serverside only? Cause if so, I can get the creation bit working, just not the velocity.
try calling physics related code after Spawn() (including GetPhysicsObject)
Got it working now, seems to work for the most part by translating the bone's velocity, angles ect... from the player to the model, thanks for the help though everyone.
Sorry, you need to Log In to post a reply to this thread.