Jump to content

Yue

Members
  • Posts

    2,449
  • Joined

  • Last visited

Everything posted by Yue

  1. What happens is that the ideal would be to use SetPosition, and SetRotation to update the position and rotation of the bones. But the position and rotation update is not perfect, the character has death cramps, convulses. Then it is impossible to release the skeleton to apply an animation in which for example after a fall an animation of standing up is activated. Now, when using SetParent, the ragdoll looks fluid without strange things, but the skeleton cannot be released to generate animations after the ragdoll effect. What I can do is what you mention, position after the restoration the rigid bodies to a central position and set the friction to zero, so that in slopes it doesn't look like it's on ice. Translated with www.DeepL.com/Translator (free version)
  2. The war with the ragdoll goes as follows: it is impossible to restore an animation when the character is hit by a vehicle and gets back on its feet. This is because the commands SetPosition, GetRotation in LE 4.6 produce a death shudder, like a déjà vu in the best style of the matrix, I do not know if to say that it convulses, or is possessed. For that reason it is better to use SetParent, this implies not being able to make the restoration in the best style of GTA V. This cannot be done. https://thumbs.gfycat.com/FlickeringOrderlyAplomadofalcon-size_restricted.gif https://thumbs.gfycat.com/HeartyMistyIberianmole-max-1mb.gif Then, the ragdoll, it will only be possible to unleash the death of the character. And you can reset the character without problems, to return it to a checkpoint to continue the game. https://j.gifs.com/J6j5ny.gif Closed case. --||########################################|| --|| Proyecto : Mars. || --|| Programador : Yue Rexie. || --|| Fichero : CRagdoll.lua. || --||########################################|| --|| Notas : Clase CPRagdoll que || --|| crea el objeto Ragdoll || --||########################################|| CRagdoll={} function CRagdoll:Create(entity) local this={} this.window = nil this.world = nil this.player = nil this.r = nil this.bHead = nil this.bThorax = nil this.bStomach = nil this.bNavel = nil this.bPelvis = nil function this:Start() self.window = Window:GetCurrent() self.world = World:GetCurrent() self.player = entity self.r = false self:GetBones() self:GetBodies() end function this:GetBones() --**Trunk** self.bHead = self.player:FindChild("mixamorig:Head") self.bThorax = self.player:FindChild("mixamorig:Spine2") self.bStomach = self.player:FindChild("mixamorig:Spine1") self.bNavel = self.player:FindChild("mixamorig:Spine") self.bPelvis = self.player:FindChild("mixamorig:Hips") --**Arms** self.bRShoul = self.player:FindChild("mixamorig:RightArm") self.bRArm = self.player:FindChild("mixamorig:RightForeArm") self.bRHand = self.player:FindChild("mixamorig:RightHand") self.bLShoul = self.player:FindChild("mixamorig:LeftArm") self.bLArm = self.player:FindChild("mixamorig:LeftForeArm") self.bLHand = self.player:FindChild("mixamorig:LeftHand") --**Legs** self.bRLeg = self.player:FindChild("mixamorig:RightUpLeg") self.bRKnee = self.player:FindChild("mixamorig:RightLeg") self.bLLeg = self.player:FindChild("mixamorig:LeftUpLeg") self.bLKnee = self.player:FindChild("mixamorig:LeftLeg") end function this:GetBodies() --**Trunk** self.mHead = self.world:FindEntity("BodyHead") self.mThorax = self.world:FindEntity("BodyThorax") self.mStomach = self.world:FindEntity("BodyStomach") self.mNavel = self.world:FindEntity("BodyNavel") self.mPelvis = self.world:FindEntity("BodyPelvis") --**Arms** self.mRShoul = self.world:FindEntity("BodyRShoul") self.mRArm = self.world:FindEntity("BodyRArm") self.mRHand = self.world:FindEntity("BodyRHand") self.mLShoul = self.world:FindEntity("BodyLShoul") self.mLArm = self.world:FindEntity("BodyLArm") self.mLHand = self.world:FindEntity("BodyLHand") --**Legs** self.mRLeg = self.world:FindEntity("BodyRLeg") self.mRKnee = self.world:FindEntity("BodyRKnee") self.mLLeg = self.world:FindEntity("BodyLLeg") self.mLKnee = self.world:FindEntity("BodyLKnee") end function this:SetPosition() --**Trunk** self.mHead:SetPosition(self.bHead:GetPosition(true),true) self.mThorax:SetPosition(self.bThorax:GetPosition(true),true) self.mStomach:SetPosition(self.bStomach:GetPosition(true),true) self.mNavel:SetPosition(self.bNavel:GetPosition(true),true) self.mPelvis:SetPosition(self.bPelvis:GetPosition(true),true) --**Arms** self.mRShoul:SetPosition(self.bRShoul:GetPosition(true),true) self.mRArm:SetPosition(self.bRArm:GetPosition(true),true) self.mRHand:SetPosition(self.bRHand:GetPosition(true),true) self.mLShoul:SetPosition(self.bLShoul:GetPosition(true),true) self.mLArm:SetPosition(self.bLArm:GetPosition(true),true) self.mLHand:SetPosition(self.bLHand:GetPosition(true),true) --**Legs** self.mRLeg:SetPosition(self.bRLeg:GetPosition(true),true) self.mRKnee:SetPosition(self.bRKnee:GetPosition(true),true) self.mLLeg:SetPosition(self.bLLeg:GetPosition(true),true) self.mLKnee:SetPosition(self.bLKnee:GetPosition(true),true) end function this:SetRotation() --**Trunk** self.mHead:SetRotation(self.bHead:GetRotation(true),true) self.mThorax:SetRotation(self.bThorax:GetRotation(true),true) self.mStomach:SetRotation(self.bStomach:GetRotation(true),true) self.mNavel:SetRotation(self.bNavel:GetRotation(true),true) self.mPelvis:SetRotation(self.bPelvis:GetRotation(true),true) --**Arms** self.mRShoul:SetRotation(self.bRShoul:GetRotation(true),true) self.mRArm:SetRotation(self.bRArm:GetRotation(true),true) self.mRHand:SetRotation(self.bRHand:GetRotation(true),true) self.mLShoul:SetRotation(self.bLShoul:GetRotation(true),true) self.mLArm:SetRotation(self.bLArm:GetRotation(true),true) self.mLHand:SetRotation(self.bLHand:GetRotation(true),true) --**Legs** self.mRLeg:SetRotation(self.bRLeg:GetRotation(true),true) self.mRKnee:SetRotation(self.bRKnee:GetRotation(true),true) self.mLLeg:SetRotation(self.bLLeg:GetRotation(true),true) self.mLKnee:SetRotation(self.bLKnee:GetRotation(true),true) end function this:CreateJoints() --**Trunk** self.jThoraxHead = Joint:Ball(self.bHead:GetPosition(true).x, self.bHead:GetPosition(true).y, self.bHead:GetPosition(true).z, self.mThorax, self.mHead) self.jThoraxHead:EnableLimits() self.jThoraxHead:SetLimits(45,45) self.jStomachThorax = Joint:Hinge(self.mThorax:GetPosition(true).x, self.mThorax:GetPosition(true).y, self.mThorax:GetPosition(true).z,1,0,0, self.mStomach, self.mThorax ) self.jStomachThorax:EnableLimits() self.jStomachThorax:SetLimits(-5,15) self.jNavelStomach = Joint:Hinge(self.mStomach:GetPosition(true).x, self.mStomach:GetPosition(true).y, self.mStomach:GetPosition(true).z, 1,0,0, self.mNavel, self.mStomach ) self.jNavelStomach:EnableLimits() self.jNavelStomach:SetLimits(-5,15) self.jPelvisNavel = Joint:Hinge( self.mNavel:GetPosition(true).x, self.mNavel:GetPosition(true).y, self.mNavel:GetPosition(true).z, 1,0,0, self.mPelvis, self.mNavel ) self.jPelvisNavel:EnableLimits() self.jPelvisNavel:SetLimits(-5,15) --**Arms** self.jRShoulThorax = Joint:Ball(self.bRShoul:GetPosition(true).x, self.bRShoul:GetPosition(true).y, self.bRShoul:GetPosition(true).z, self.mRShoul, self.mThorax) self.jRShoulThorax:EnableLimits() self.jRShoulThorax:SetLimits(90,90) self.jRArmShoul = Joint:Hinge(self.bRArm:GetPosition(true).x, self.bRArm:GetPosition(true).y, self.bRArm:GetPosition(true).z, 0,1,0, self.mRArm, self.mRShoul ) self.jRArmShoul:EnableLimits() self.jRArmShoul:SetLimits(-90,0) self.jRHandArm = Joint:Hinge(self.bRHand:GetPosition(true).x, self.bRHand:GetPosition(true).y, self.bRHand:GetPosition(true).z, 0,0,1, self.mRHand, self.mRArm ) self.jRHandArm:EnableLimits() self.jRHandArm:SetLimits(-55,55) self.jLShoulThorax = Joint:Ball(self.bLShoul:GetPosition(true).x, self.bLShoul:GetPosition(true).y, self.bLShoul:GetPosition(true).z, self.mLShoul, self.mThorax) self.jLShoulThorax:EnableLimits() self.jLShoulThorax:SetLimits(90,90) self.jLArmShoul = Joint:Hinge(self.bLArm:GetPosition(true).x, self.bLArm:GetPosition(true).y, self.bLArm:GetPosition(true).z, 0,1,0, self.mLArm, self.mLShoul ) self.jLArmShoul:EnableLimits() self.jLArmShoul:SetLimits(0,-90) self.jLHandArm = Joint:Hinge(self.bLHand:GetPosition(true).x, self.bLHand:GetPosition(true).y, self.bLHand:GetPosition(true).z, 0,0,1, self.mLHand, self.mLArm ) self.jLHandArm:EnableLimits() self.jLHandArm:SetLimits(-55,55) --**Legs** self.jRLegPelvis = Joint:Ball(self.bPelvis:GetPosition(true).x, self.bPelvis:GetPosition(true).y, self.bPelvis:GetPosition(true).z, self.mRLeg, self.mPelvis ) self.jRLegPelvis:EnableLimits() self.jRLegPelvis:SetLimits(10,90) self.jRKneeLeg = Joint:Hinge(self.bRKnee:GetPosition(true).x, self.bRKnee:GetPosition(true).y, self.bRKnee:GetPosition(true).z, 1,0,0, self.mRKnee, self.mRLeg ) self.jRKneeLeg:EnableLimits() self.jRKneeLeg:SetLimits(-90,0) self.jLLegPelvis = Joint:Ball(self.bPelvis:GetPosition(true).x, self.bPelvis:GetPosition(true).y, self.bPelvis:GetPosition(true).z, self.mLLeg, self.mPelvis ) self.jLLegPelvis:EnableLimits() self.jLLegPelvis:SetLimits(10,90) self.jLKneeLeg = Joint:Hinge(self.bLKnee:GetPosition(true).x, self.bLKnee:GetPosition(true).y, self.bLKnee:GetPosition(true).z, 1,0,0, self.mLKnee, self.mLLeg ) self.jLKneeLeg:EnableLimits() self.jLKneeLeg:SetLimits(-90,0) end function this:DestroyJoints() --**Trunk** self.jThoraxHead:Release() self.jStomachThorax:Release() self.jNavelStomach:Release() self.jPelvisNavel:Release() --**Arms** self.jRShoulThorax:Release() self.jRArmShoul:Release() self.jRHandArm:Release() self.jLShoulThorax:Release() self.jLArmShoul:Release() self.jLHandArm:Release() --**Legs** self.jRLegPelvis:Release() self.jRKneeLeg:Release() self.jLLegPelvis:Release() self.jLKneeLeg:Release() end function this:SetMass(mass) --**Trunk** self.mHead:SetMass(mass) self.mThorax:SetMass(mass) self.mStomach:SetMass(mass) self.mNavel:SetMass(mass) self.mPelvis:SetMass(mass) --**Arms** self.mRShoul:SetMass(mass) self.mRArm:SetMass(mass) self.mRHand:SetMass(mass) self.mLShoul:SetMass(mass) self.mLArm:SetMass(mass) self.mLHand:SetMass(mass) --**Legs** self.mRLeg:SetMass(mass) self.mRKnee:SetMass(mass) self.mLLeg:SetMass(mass) self.mLKnee:SetMass(mass) end function this:UpdateBones() self.bHead:SetPosition(self.mHead:GetPosition(true),true) self.bHead:SetRotation(self.mHead:GetRotation(true),true) self.bThorax:SetPosition(self.mThorax:GetPosition(true),true) self.bThorax:SetRotation(self.mThorax:GetRotation(true),true) self.bStomach:SetPosition(self.mStomach:GetPosition(true),true) self.bStomach:SetRotation(self.mStomach:GetRotation(true),true) end function this:SetParent() --**Trunk** self.bHead:SetParent(self.mHead,true) self.bThorax:SetParent(self.mThorax,true) self.bStomach:SetParent(self.mStomach,true) self.bNavel:SetParent(self.mNavel,true) self.bPelvis:SetParent(self.mPelvis,true) --**Arms** self.bRShoul:SetParent(self.mRShoul,true) self.bRArm:SetParent(self.mRArm,true) self.bRHand:SetParent(self.mRHand,true) self.bLShoul:SetParent(self.mLShoul,true) self.bLArm:SetParent(self.mLArm,true) self.bLHand:SetParent(self.mLHand,true) --**Legs** self.bRLeg:SetParent(self.mRLeg,true) self.bRKnee:SetParent(self.mRKnee,true) self.bLLeg:SetParent(self.mLLeg,true) self.bLKnee:SetParent(self.mLKnee,true) end function this:Update() if self.window:KeyHit(Key.R) then if self.r == false then self:SetPosition() self:SetRotation() self:CreateJoints() self:SetParent() self:SetMass(1.0) self.r = true end end if self.r == true then self.player:SetPosition(self.bPelvis:GetPosition(true),true) --self:UpdateBones() end if Window:GetCurrent():KeyHit(Key.E) then self:SetMass(0) self:DestroyJoints() self.player:Release() end end this:Start() return ( this ) end
  3. When you are not making a video game, but you are struggling with lua script and you learn the hard way how it works. This is the right thing to do, run away from the FindEntity command in the world, it does not work as expected. CRagdoll={} function CRagdoll:Create(entity) local this={} this.player = nil this.bHead = nil function this:Start() self.player = entity self.bHead = self.player:FindChild("bone:Head") System:Print(self.bHead) end function this:Update() if Window:GetCurrent():KeyHit(Key.E) then self.player:Release() end end this:Start() return ( this ) end
  4. We continue to fight with the ragdoll.
  5. I am trying to restart the player after his death to a specific point on the map, as you can't create an animation to make him stand up, but this doesn't work for me, after deleting the character and creating a new one about three times this gets very slow. function this:Update() if Window:GetCurrent():KeyHit(Key.R) then if self.r == false then self.player2 = self.player:Instance(),"Yue" self.player:StopAnimation() self:SetPositionMeshs() self:SetRotationMeshs() self:SetParent(true) self:CreateJoints() self:SetMass(1.0) self.r = true end end if self.r == true then --self:UpdateBones() if Window:GetCurrent():KeyHit(Key.T) then self:SetParent(false) self.player:Release() self.player = self.player2 --self.player2:Release() --self.r=false end end end I think the truth is that I'm a very bad programmer and I'm going to give up on this, I always run into certain difficult obstacles and the same process and get nowhere.
  6. These commands do not work correctly when updating the ragdoll effect. function this:UpdateBones() --**Trunck** self.bHead:SetPosition(self.mHead:GetPosition(true),true) self.bHead:SetRotation(self.mHead:GetRotation(true),true) self.bThorax:SetPosition(self.mThorax:GetPosition(true),true) self.bThorax:SetRotation(self.mThorax:GetRotation(true),true) self.bStomach:SetPosition(self.mStomach:GetPosition(true),true) self.bStomach:SetRotation(self.mStomach:GetRotation(true),true) self.bNavel:SetPosition(self.mNavel:GetPosition(true),true) self.bNavel:SetRotation(self.mNavel:GetPosition(true),true) self.bPelvis:SetPosition(self.mPelvis:GetPosition(true),true) self.bPelvis:SetRotation(self.mPelvis:GetRotation(true),true) --**Legs** self.bRLeg:SetPosition(self.mRLeg:GetPosition(true),true) self.bRLeg:SetRotation(self.mRLeg:GetRotation(true),true) self.bLLeg:SetPosition(self.mLLeg:GetPosition(true),true) self.bLLeg:SetRotation(self.mLLeg:GetRotation(true),true) self.bRKnee:SetPosition(self.mRKnee:GetPosition(true),true) self.bRKnee:SetRotation(self.mRKnee:GetRotation(true),true) self.bLKnee:SetPosition(self.mLKnee:GetPosition(true),true) self.bLKnee:SetRotation(self.mLKnee:GetRotation(true),true) self.bRFoot:SetPosition(self.mRFoot:GetPosition(true),true) self.bRFoot:SetRotation(self.mRFoot:GetRotation(true),true) self.bLFoot:SetPosition(self.mLFoot:GetPosition(true),true) self.bLFoot:SetRotation(self.mLFoot:GetRotation(true),true) --**Arms** self.bRShoul:SetPosition(self.mRShoul:GetPosition(true),true) self.bRShoul:SetRotation(self.mRShoul:GetRotation(true),true) self.bLShoul:SetPosition(self.mLShoul:GetPosition(true),true) self.bLShoul:SetRotation(self.mLShoul:GetRotation(true),true) self.bRArm:SetPosition(self.mRArm:GetPosition(true),true) self.bRArm:SetRotation(self.mRArm:GetRotation(true),true) self.bLArm:SetPosition(self.mLArm:GetPosition(true),true) self.bLArm:SetRotation(self.mLArm:GetRotation(true),true) self.bRHand:SetPosition(self.mRHand:GetPosition(true),true) self.bRHand:SetRotation(self.mRHand:GetRotation(true),true) self.bLHand:SetPosition(self.mLHand:GetPosition(true),true) self.bLHand:SetRotation(self.mLHand:GetRotation(true),true) end The rag doll effect looks wrong. TEMP 2021-02-17 20-26-51.mp4 In that case it is better to use SetParent, but it would be impossible to make an animation that after the ragdoll effect is executed, the character stands up by means of an animation. I guess there is nothing else that can be done. Working the right way with SetParent TEMP 2021-02-17 20-31-25.mp4
  7. Returning to the process of the rag doll, after being frustrated for a while without understanding what happens when resetting the mesh and its bones. I discovered by brute force that I should not use SetParent on the bones, but rather SetPosition and SetRotation.
  8. No, the idea is to reuse the system again and have it ready for when you restart the game. This is also with a view to the ragdoll being activated and the player standing up, like in gta V when run over by a car, but it looks like the skeleton is unhooked from the mesh.
  9. When the player triggers his death, it triggers the ragdoll effect and the character is lying on the ground. The next step is to release the rigid bodies of their parents bones, I have tried to position the player back to the starting point, but this does not happen, only the player controller remains moving, but the character, the mesh remains in the place of the ragdoll effect, I have tried to use an animation but it does not work. I think I may have to reload the character and remove that one. any suggestions? Translated with www.DeepL.com/Translator (free version) function this:Start() if self.r == true then self:FindMeshs() self:FindBones() self:SetPosition(true) self:SetRotation() self:SetParent(true) self:SetMass(1.0) self:GetPosition() self:CreateJoints(true) self.player:SetPhysicsMode(Entity.RigidBodyPhysics) self.player:SetMass(0.0) end end function this:End() self:SetParent(false) --self:SetPosition(false) --self:SetMass(0) --self:CreateJoints(false) self.player:SetPhysicsMode(Entity.CharacterPhysics) self.player:SetMass(10) --self.player:SetPosition(0,0,0,false) self.player:SetColor(0,1,0) end
  10. self.c = 0 if Window:GetCurrent():KeyHit(Key.C) then self.c = 1 - self.c end if self.c == 1 then self.tc = true else self.tc = false end if self.player:SetInput(self.ang,self.vel,0,self.jForce, self.tc ) Un inconveniente por ahora es que al pasar por debajo de la apertura, si se presiona la tecla C de nuevo el personaje se pone de pie. La posible solución a esto es poner un cepillo invisible en el pasillo, para que la tecla C, no active que el personaje se ponga de pie. Y el tipo de colisión pare este cepillo sería trigger.
  11. I can't understand the question, the translator doesn't help me much. The crouching animation is maintained by pressing the C key.
  12. function Script:Start() self.c = World:GetCurrent():FindEntity("Camera") self.c:SetRange(0.001,1000) --<<<<<<<<<<<< Error. end Not Error. Script.camera = nil --entity "Camera :" --Fix Error. function Script:Start() self.c = World:GetCurrent():FindEntity("Camera") self.c:SetRange(0.001,1000) -- Not Error. end
×
×
  • Create New...