Jump to content

[Continue Work ]Radgoll progress


Yue
 Share

Recommended Posts

--##################################################
--# Proytecto 	: Mars.
--# Scripter  	: Yue Rexie.
--# Sitio Web	: https://www.iris3dgames.xyz
--# Fichero		: CRagDoll.lua
--##################################################
--# Notas		: Clase CRagdoll para crear 
--#				  el efecot muñeco de trapo.
--##################################################

CRagDoll={}

	function CRagDoll:Create()

		local this={}

			this.world = World:GetCurrent()
			this.player= this.world:FindEntity("Yue")
			this.r    = false 

			function this:Start()

				if self.r == true then 
					self:FindMeshs()
					self:FindBones()
					self:SetPosition()
					self:SetRotation()
					self:SetParent()
					self:SetMass()
					self:GetPosition()
					self:CreateJoints()
				end
					
			end
			
	
			function this:FindMeshs()
				--**Trunk**
				self.mHead 	 = self.world:FindEntity("Head")
				self.mThorax = self.world:FindEntity("Thorax")
				self.mNavel  = self.world:FindEntity("Navel")
				self.mPelvis = self.world:FindEntity("Pelvis")
				--**Arms**
				self.mRShoulder= self.world:FindEntity("R_Shoulder")
				self.mLShoulder= self.world:FindEntity("L_Shoulder")
				self.mRArm	 = self.world:FindEntity("R_Arm")
				self.mLArm   = self.world:FindEntity("L_Arm")
				self.mRHand  = self.world:FindEntity("R_Hand")
				self.mLHand  = self.world:FindEntity("L_Hand")
				--**Legs**
				self.mRLeg	 = self.world:FindEntity("R_Leg")
				self.mLLeg	 = self.world:FindEntity("L_Leg")
				self.mRKnee  = self.world:FindEntity("RKnee")
				self.mLKnee  = self.world:FindEntity("LKnne")			
				
			end
			
			function this:FindBones()
				--**Trunk**
				self.bHead   = self.player:FindChild("mixamorig_Head")
				self.bThorax = self.player:FindChild("mixamorig_Spine2")
				self.bNavel  = self.player:FindChild("mixamorig_Spine")
				self.bPelvis = self.player:FindChild("mixamorig_Hips")
				--**Arms**
				self.bRShoulder=self.player:FindChild("mixamorig_RightArm")
				self.bLShoulder=self.player:FindChild("mixamorig_LeftArm")
				self.bRArm   =  self.player:FindChild("mixamorig_RightForeArm")
				self.bLArm	 =  self.player:FindChild("mixamorig_LeftForeArm")
				self.bRHand  =  self.player:FindChild("mixamorig_RightHand")
				self.bLHand  =  self.player:FindChild("mixamorig_LeftHand")
				--**Legs**                             
				self.bRLeg   = self.player:FindChild("mixamorig_RightUpLeg")
				self.bLLeg	 = self.player:FindChild("mixamorig_LeftUpLeg")
				self.bRKnee  = self.player:FindChild("mixamorig_RightLeg")
				self.bLKnee	 = self.player:FindChild("mixamorig_LeftLeg")

			end
			
			function this:SetPosition()
				--**Trunk**
				self.mHead:SetPosition(self.bHead:GetPosition(true),true)
				self.mThorax:SetPosition(self.bThorax:GetPosition(true),true)
				self.mNavel:SetPosition(self.bNavel:GetPosition(true),true)
				self.mPelvis:SetPosition(self.bPelvis:GetPosition(true),true)
				--**Arms**
				self.mRShoulder:SetPosition(self.bRShoulder:GetPosition(true),true)
				self.mLShoulder:SetPosition(self.bLShoulder:GetPosition(true),true)
				self.mRArm:SetPosition(self.bRArm:GetPosition(true),true)
				self.mLArm:SetPosition(self.bLArm:GetPosition(true),true)
				self.mRHand:SetPosition(self.bRHand:GetPosition(true),true)
				self.mLHand:SetPosition(self.bLHand:GetPosition(true),true)
				--**Legs**
				self.mRLeg:SetPosition(self.bRLeg:GetPosition(true),true)
				self.mLLeg:SetPosition(self.bLLeg:GetPosition(true),true)
				self.mRKnee:SetPosition(self.bRKnee: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.mNavel:SetRotation(self.bNavel:GetRotation(true),true)
				self.mPelvis:SetRotation(self.bPelvis:GetRotation(true),true)
				--**Arms**
				self.mRShoulder:SetRotation(self.bRShoulder:GetRotation(true),true)
				self.mLShoulder:SetRotation(self.bLShoulder:GetRotation(true),true)
				self.mRArm:SetRotation(self.bRArm:GetRotation(true),true)
				self.mLArm:SetRotation(self.bLArm:GetRotation(true),true)
				self.mRHand:SetRotation(self.bRHand:GetRotation(true),true)
				self.mLHand:SetRotation(self.bLHand:GetRotation(true),true)
				--**Legs**
				self.mRLeg:SetRotation(self.bRLeg:GetRotation(true),true)
				self.mLLeg:SetRotation(self.bLLeg:GetRotation(true),true)
				self.mRKnee:SetRotation(self.bRKnee:GetRotation(true),true)
				self.mLKnee:SetRotation(self.bLKnee:GetRotation(true),true)

			end

			function this:SetParent()
				--**Trunk**
				self.bHead:SetParent(self.mHead,true)
				self.bThorax:SetParent(self.mThorax,true)
				self.bNavel:SetParent(self.mNavel,true)
				self.bPelvis:SetParent(self.mPelvis,true)
				--**Arms**
				self.bRShoulder:SetParent(self.mRShoulder,true)
				self.bLShoulder:SetParent(self.mLShoulder,true)
				self.bRArm:SetParent(self.mRArm,true)
				self.bLArm:SetParent(self.mLArm,true)
				self.bRHand:SetParent(self.mRHand,true)
				self.bLHand:SetParent(self.mLHand,true)
				--**Legs**--
				self.bRLeg:SetParent(self.mRLeg,true)
				self.bLLeg:SetParent(self.mLLeg,true)
				self.bRKnee:SetParent(self.mRKnee)
				self.bLKnee:SetParent(self.mLKnee)
				
			end
			

			function this:SetMass()
				--**Trunk**
				self.mHead:SetMass(0.1)
				self.mThorax:SetMass(0.1)
				self.mNavel:SetMass(0.1)
				self.mPelvis:SetMass(0.1)
				--**Arms**
				self.mRShoulder:SetMass(0.1)
				self.mLShoulder:SetMass(0.1)
				self.mRArm:SetMass(0.1)
				self.mLArm:SetMass(0.1)
				self.mRHand:SetMass(0.1)
				self.mLHand:SetMass(0.1)
				--**Legs**--
				self.mRLeg:SetMass(0.1)
				self.mLLeg:SetMass(0.1)
				self.mRKnee:SetMass(0.1)
				self.mLKnee:SetMass(0.1)
			end

			function this:GetPosition()
				--**Trunk**
				self.posHead 		= self.mHead:GetPosition(true)
				self.posThorax 		= self.mThorax:GetPosition(true)
				self.posNavel   	= self.mNavel:GetPosition(true)
				self.posPelvis  	= self.mNavel:GetPosition(true)
				--**Arms**
				self.posRShoulder	= self.mRShoulder:GetPosition(true)
				self.posLShoulder	= self.mLShoulder:GetPosition(true)
				self.posRArm		= self.mRArm:GetPosition(true)
				self.posLArm		= self.mLArm:GetPosition(true)
				self.posRHand		= self.mRHand:GetPosition(true)
				self.posLHand		= self.mLHand:GetPosition(true)
				--**Legs**
				self.posRleg		= self.mRLeg:GetPosition(true)
				self.posLLeg		= self.mLLeg:GetPosition(true)
				self.posRKnee		= self.mRKnee:GetPosition(true)
				self.posLKnee		= self.mLKnee:GetPosition(true)
			end

			function this:CreateJoints()

			end
		
			

		return ( this )

	end

 

  • Like 2
  • Thanks 1

 

 

Link to comment
Share on other sites

Ragdoll finish.

 

	function this:CreateJoints()
				--**Trunk**
				self.jThoraxHead 	= Joint:Ball(self.posHead.x, self.posHead.y, self.posHead.z, self.mThorax, self.mHead)
				self.jThoraxHead:EnableLimits()
				self.jThoraxHead:SetLimits(35,35)
				
				self.jNavelThorax	= Joint:Hinge(self.posThorax.x, self.posThorax.y, self.posThorax.z, 1,0,0,self.mNavel, self.mThorax)
				self.jNavelThorax:EnableLimits()
				self.jNavelThorax:SetLimits(0,45)

				self.jPelvisNavel	= Joint:Ball(self.posNavel.x, self.posNavel.y, self.posNavel.z, self.mPelvis, self.mNavel)
				self.jPelvisNavel:EnableLimits()
				self.jPelvisNavel:SetLimits(0,0)
				


	
				--**Arms**
				self.jRThoraxRShoulder	= Joint:Ball(self.posRShoulder.x ,self.posRShoulder.y, self.posRShoulder.z, self.mRShoulder, self.mThorax)
				self.jRThoraxRShoulder:EnableLimits()
				self.jRThoraxRShoulder:SetLimits(45,90)

				self.jLThoraxLShoulder	= Joint:Ball(self.posLShoulder.x, self.posLShoulder.y, self.posLShoulder.z, self.mLShoulder, self.mThorax)
				self.jLThoraxLShoulder:EnableLimits()
				self.jLThoraxLShoulder:SetLimits(45,90)
				
				self.jRArmRShoulder	= Joint:Hinge(self.posRArm.x, self.posRArm.y, self.posRArm.z, 0,1,0, self.mRArm, self.mRShoulder ) 
				self.jRArmRShoulder:EnableLimits()
				self.jRArmRShoulder:SetLimits(0,90)

				self.jLArmLShoulder	= Joint:Hinge(self.posLArm.x, self.posLArm.y, self.posLArm.z,0,1,0, self.mLArm, self.mLShoulder ) 
				self.jLArmLShoulder:EnableLimits()
				self.jLArmLShoulder:SetLimits(0,-90)

			
				self.jRHandRArm		= Joint:Ball(self.posRHand.x,self.posRHand.y, self.posRHand.z, self.mRHand, self.mRArm )
				self.jRHandRArm:EnableLimits()
				self.jRHandRArm:SetLimits(45,45)
				
				self.jLHandLArm		= Joint:Ball(self.posLHand.x,self.posLHand.y, self.posLHand.z, self.mLHand, self.mLArm )
				self.jLHandLArm:EnableLimits()
				self.jLHandLArm:SetLimits(45,45)

				--**Legs**
				self.jRLegPelvis	= Joint:Ball(self.posPelvis.x, self.posPelvis.y, self.posPelvis.z, self.mRLeg, self.mPelvis )
				self.jRLegPelvis:EnableLimits()
				self.jRLegPelvis:SetLimits(30,30)
				
				self.jLLegPelvis	= Joint:Ball(self.posPelvis.x, self.posPelvis.y, self.posPelvis.z, self.mLLeg, self.mPelvis )
				self.jLLegPelvis:EnableLimits()
				self.jLLegPelvis:SetLimits(20,20)
				
				self.jRKneeRLeg		= Joint:Hinge(self.posRKnee.x, self.posRKnee.y, self.posRKnee.z,1,0,0, self.mRKnee, self.mRLeg )
				self.jRKneeRLeg:EnableLimits()
				self.jRKneeRLeg:SetLimits(-35,15)
					
				self.jLKneeLLeg		= Joint:Hinge(self.posLKnee.x, self.posLKnee.y, self.posLKnee.z,1,0,0, self.mLKnee, self.mLLeg )
				self.jLKneeLLeg:EnableLimits()
				self.jLKneeLLeg:SetLimits(-35,15)
		
			end

 

  • Like 1

 

 

Link to comment
Share on other sites

  • 2 weeks later...

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.
image.thumb.png.84c21cd45a3d484726b9e5c60b77fb53.png
 

  • Like 1

 

 

Link to comment
Share on other sites

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.

 

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
 

 

 

 

 

Link to comment
Share on other sites

  • Yue changed the title to [Completed] Radgoll progress.
  • Yue changed the title to Radgoll progress.

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

 

 

 

Link to comment
Share on other sites

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

 

 

 

Link to comment
Share on other sites

  • Yue changed the title to Radgoll progress.[Completed]

So in the theory I would try to release the joints and then play a simple animation to awake the character.

If you can't release the joints, maybe try to set the friction to 0, so that the joints don't generate any force, just release the control.

And I would try to Hide() the boxes to avoid strange collision problems, and to set the Mass to 0 after the ragdoll animation is finished.

  • Like 1

 

 

Link to comment
Share on other sites

6 hours ago, Marcousik said:

So in the theory I would try to release the joints and then play a simple animation to awake the character.

If you can't release the joints, maybe try to set the friction to 0, so that the joints don't generate any force, just release the control.

And I would try to Hide() the boxes to avoid strange collision problems, and to set the Mass to 0 after the ragdoll animation is finished.

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)

 

 

Link to comment
Share on other sites

Quote

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.

Sorry this is not clear for me... Do you mean "...use the skeleton to apply an animation" ?

I don't understand why you could not use the skeleton after the ragdoll goes to end ? Do you ?

 

 

Link to comment
Share on other sites

When I run the ragdoll with SetParen, assigning as parent of the bone the rigid body. The ragdoll looks decent. The thing is that when I finish the ragdoll, I can't use animations like standing up. The skeleton is already related to the rigid body. 

This could be done if I use SetPosition or SetRotation and for example the character is hit by a car and stands up, like in gta V, this is because the effect is finished and the skeleton responds to the animation, but with this method the character in full ragdoll has death cramps, it's like convulsing and it looks totally weird. 

So what is possible now is to use SetParent, but after the ragdoll effect, its death, I remove the mesh and load it again where the skeleton is perfect to resume animations. 

Translated with www.DeepL.com/Translator (free version)

 

 

function Script:Detach()
	
		self.entity = Model:Load("Models/Player/Yue.mdl")
		self.entity:SetPosition(0,8,-5)
		self.entity:SetRotation(-45,0,0)
		self.entity:SetScript("Scripts/Player/EPlayer.lua")
		self.entity:SetShadowMode(Light.Dynamic)
		
	
	
end


 

 

 

Link to comment
Share on other sites

  • Yue changed the title to [Continue Work ]Radgoll progress

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...