Jump to content

[Solved] Standing up the player after the ragdoll effect?


Yue
 Share

Recommended Posts

¿Alguna sugerencia sobre cómo hacer esto posible?

La cuestión es que no planeaba sacar esto a colación tan pronto, sin embargo, cuando mi personaje muere, el menú cambia la etiqueta del botón de estado de "REANUDAR" a "REINICIAR" y en este punto tengo que considerar esta situación.

 

image.thumb.png.aa736eefad7133bcff4927d54dc7d78b.png

 

Dentro del evento del botón Reset es donde tengo que plantear cómo resetear al jugador a su posición original.

 

elseif self.btnStart:GetText()=="RESET" then 
		showMenu = 0
		self.gui:Hide()
		Win:FadeOut()

		Win:Update()
		Time:Delay(1000)
									
										
				-- Here Reset Player.				
							

		Win:FadeIn()
end

Aquí me encuentro con un problema grave, tengo que soltar los huesos que están relacionados con los cuerpos rígidos que simulan el efecto ragdoll. Pero ninguna animación que lance funciona. Es como si el esqueleto estuviera suelto de la malla, no sé qué podría ser.

En el futuro esperaría que el personaje se pusiera de pie bajo ciertas circunstancias, pero en este punto parece que no sería posible, tengo que eliminar el personaje posiblemente y cargarlo por guión a su posición original.

Así que estoy atascado en esto, cualquier sugerencia es bienvenida.

Traducido con www.DeepL.com/Translator (versión gratuita)

 

Mars.jpg.89ab63a64eebc1f5ada0ab82b66a1f8c.jpg

 

 

Link to comment
Share on other sites

Is there a problem with just loading a new instance of the player? It might be easier to recreate a new one rather than trying to undo all the things you did to it.

  • Like 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

52 minutes ago, Josh said:

¿Hay algún problema con solo cargar una nueva instancia del reproductor? Podría ser más fácil recrear uno nuevo en lugar de tratar de deshacer todas las cosas que le hiciste.

I'm thinking of the instance, it would be when the character just before dying creates that copy in memory.  But I am not clear if when creating that instance the script is still hooked and its respective property changes continue to be functional.

But I just have to test it and I'll let you know. ;)


Motor de juego Leadwerks <<<  Instance

Mars.jpg.89ab63a64eebc1f5ada0ab82b66a1f8c.jpg

 

 

Link to comment
Share on other sites

Just call Model::Load before your delete the previous player, and it will create a fast instance. This is better anyways, because as you add more to the game you don't have to keep adding code to revert the player back to its original state.

  • Upvote 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

elseif self.btnStart:GetText()=="RESET" then 
		showMenu = 0
		self.gui:Hide()
		Win:FadeOut()

		Win:Update()
		Time:Delay(1000)
		self.Hud.script:ResetLife()
		self.pos = World:GetCurrent():FindEntity("ToolsBox"):GetPosition(true)
		World:GetCurrent():FindEntity("Yue"):SetPosition(self.pos.x, self.pos.y+1, self.pos.z)
		World:GetCurrent():FindEntity("Yue"):SetPhysicsMode(Entity.CharacterPhysics)
		World:GetCurrent():FindEntity("Yue"):SetCollisionType(Collision.Prop)
		World:GetCurrent():FindEntity("Yue"):SetMass(10)
										
										
							

		Win:FadeIn()
end

The most complicated part of all this, in my opinion, is to put all the systems together to make it work as expected. 

For some reason the coordinates that I have initially where the character starts does not work with SetPosition, what I am doing is to use a reference model to position the model to its initial position, this would be like a CheckPoint. The ragdoll system at this point does not launch, the player is positioned at the coordinate, but does not react to the force of gravity, it remains suspended in the air unless I press the move key.

What I am doing is breaking this into smaller pieces, the important thing here is that the positioning is done to that initial point where the player starts.  

 

 

 

 

 

Mars.jpg.89ab63a64eebc1f5ada0ab82b66a1f8c.jpg

 

 

Link to comment
Share on other sites

This is a tremendous pain in the balls to have to deal with.  :D

World:GetCurrent():FindEntity("Yue").script.player.meshPlayer:SetPhysicsMode(Entity.CharacterPhysics)

he point is that this for some reason that I do not understand does not work within the respective event of the button. 

This I have to use it in another script, inside this button I can without any problem restore the original position of the player after his death.

 

elseif self.btnStart:GetText()=="RESET" then 
		showMenu = 0
		self.gui:Hide()
		Win:FadeOut()

		Win:Update()
		Time:Delay(1000)
		self.Hud.script:ResetLife()
		self.pos = World:GetCurrent():FindEntity("ToolsBox"):GetPosition(true)
		World:GetCurrent():FindEntity("Yue"):SetPosition(self.pos.x, self.pos.y, self.pos.z)
		-- No Work.
		--World:GetCurrent():FindEntity("Yue").script.player.meshPlayer:SetPhysicsMode(Entity.CharacterPhysics)
		--World:GetCurrent():FindEntity("Yue").script.player.meshPlayer:SetCollisionType(Collision.Character)
		World:GetCurrent():FindEntity("Yue"):SetMass(10)
		World:GetCurrent():FindEntity("Yue"):AddForce(0,1,0)
										
									
		Win:FadeIn()
	end
elseif event.source == self.btnOptions then

Now I have to find a solution to the ragdoll effect.

Mars.jpg.89ab63a64eebc1f5ada0ab82b66a1f8c.jpg

 

 

Link to comment
Share on other sites

This is my suffering today. In thinking ahead in putting the character standing after the ragdoll effect happens that the skeleton is separated from the mesh, and does not move to its position where the player's position on the character controller is reset. 

Obviously at this point you would have to think about reloading the character, and not implement standing up the player. But I'd still like to try that, so I'm trying to think what I can do.

 

 

 

  • Haha 1

Mars.jpg.89ab63a64eebc1f5ada0ab82b66a1f8c.jpg

 

 

Link to comment
Share on other sites

I'll go to sleep, I think I'm getting somewhere with this.
First of all I don't get to load the character into the map, what I do independently via a script is load it into memory. It works fine, I can reset the position to the initial control point without any problem every time the character dies, however I am in a problem, and it is an option that is in the map called character angle, that is in the properties of the entity in the map. 
 

image.png.8d280e79ab7e9de3cc51838a887b022a.png

This option is used to orient the correct rotation of the character in its movement, but through code I don't know how to do it. 

That is to say, when I load the player with the map, I set this value to 180, and my character runs in the correct direction when he moves the keys. But as I am loading the player by code this changes everything. 

 

 

 

Mars.jpg.89ab63a64eebc1f5ada0ab82b66a1f8c.jpg

 

 

Link to comment
Share on other sites

Solved. The player will not stand up, after his death he is restored to a checkpoint. The solution was to load the player via script code and not on the map.

elseif self.btnStart:GetText()=="RESET" then 
		showMenu = 0
		self.gui:Hide()
		Win:FadeOut()

												
		self.Hud.script:ResetLife()
		player.script.Helmet:SetParent(nil)
		player.script.Backpack:SetParent(nil)
		player.script.RPlayer:FreeJoints()
		player.script.RPlayer:FreeMeshs()
		player:Release()
											
		player = Model:Load("Assets/Models/Player/Yue.mdl")
		player:SetKeyValue("name","Yue")
		player:SetRotation(0,0,0)
										   		   player:SetPosition(World:GetCurrent():FindEntity("ToolsBox"):GetPosition(true).x,World:GetCurrent():FindEntity("ToolsBox"):GetPosition(true).y+1,World:GetCurrent():FindEntity("ToolsBox"):GetPosition(true).z,true)
		player:SetScript("Scripts/Game/Player/Player.lua",false)
		player.script.hud = World:GetCurrent():FindEntity("Hud")
		player.script.Helmet = World:GetCurrent():FindEntity("Helmet")
		player.script.Backpack = World:GetCurrent():FindEntity("Mochila")
		player.script:Start()
		player:SetMass(10)									
		Time:Delay(500)
								
										
									
		Win:FadeIn()
end

 

  • Like 1

Mars.jpg.89ab63a64eebc1f5ada0ab82b66a1f8c.jpg

 

 

Link to comment
Share on other sites

  • Yue changed the title to [Solved] Standing up the player after the ragdoll effect?

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...