-
Posts
2,449 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Downloads
Everything posted by Yue
-
Animations Walk, Idle. System Camera Orbit on player. --################################################## --# Proytecto : Mars. --# Scripter : Yue Rexie. --# Sitio Web : https://www.iris3dgames.xyz --# Fichero : CPlayer.lua --################################################## --# Notas : Clase CPlayer para crear --# el objeto Jugador. --################################################## import("Scripts/Player/Classes/CCamera.lua") import("Scripts/Player/Classes/CAnimation.lua") import("Scripts/Player/Classes/CRagDoll.lua") CPlayer={} function CPlayer:New() local this={} this.world = nil this.player = nil this.ragdoll = nil this.anima = nil self.anin = nil self.camera = nil this.vel = 0.0 this.velAnim = 0.0 this.ang = 0.0 this.jForce = 0.0 function this:Create() self.world = World:GetCurrent() self.player= self.world:FindEntity("Yue") self.camera= CCamera:New() self.camera:Update() self.anima = CAnimation:Create() self.anim = self.anima.idle self.velAnim = 0.05 self.player:PlayAnimation(self.anim,self.velAnim,0.1) self.ragdoll = CRagDoll:Create() System:Print("System Player create... OK!") end function this:Update() self.camera:Update() self:Move() self.ragdoll:Update() end function this:Move() self.vel = 0.0 self.anim = self.anima.idle if Window:GetCurrent():KeyDown(Key.W) then self.anim = self.anima.walk self.ang = self.camera:GetRotationY()-180 if Window:GetCurrent():MouseDown(2) then self.ang = self.player:GetRotation(true).y end self.velAnim = 0.03 self.vel = -1.0 if Window:GetCurrent():KeyDown(Key.Shift) then self.vel = -2.0 end end if Window:GetCurrent():KeyDown(Key.S) then self.anim = self.anima.walk self.ang = self.camera:GetRotationY() if Window:GetCurrent():MouseDown(2) then self.ang = self.player:GetRotation(true).y end self.vel = -1.0 if Window:GetCurrent():KeyDown(Key.Shift) then self.vel = -2.0 end end self:Jump() self.player:SetInput(self.ang,self.vel,0,self.jForce) self.player:PlayAnimation(self.anim,self.velAnim) end function this:Jump() self.jForce = 0 if Window:GetCurrent():KeyHit(Key.Space) then if self.player:GetAirborne()== false then self.jForce = 10 end end end this:Create() return( this ) end
-
--################################################## --# Proytecto : Mars. --# Scripter : Yue Rexie. --# Sitio Web : https://www.iris3dgames.xyz --# Fichero : CPlayer.lua --################################################## --# Notas : Clase CPlayer para crear --# el objeto Jugador. --################################################## import("Scripts/Player/Classes/CRagDoll.lua") CPlayer={} function CPlayer:New() local this={} this.world = nil this.camera = nil this.pPlayer = nil this.pCamera = nil this.player = nil this.rotPP = Vec3() this.ragdoll = nil this.vel = 0.0 this.ang = 180 function this:Create() self.world = World:GetCurrent() self.camera = self.world:FindEntity("Camera") self.player = self.world:FindEntity("Yue") self.pPlayer= self.world:FindEntity("PivotPlayer") self.pCamera= self.world:FindEntity("PivotCamera") self.bNeck = self.player:FindChild("mixamorig_Head") self.pPlayer:SetPosition(self.bNeck:GetPosition(true)) --self.pPlayer:SetParent(self.bNeck,false) self.pCamera:SetPosition(self.pPlayer:GetPosition(true)) self.pCamera:SetParent(self.pPlayer,true) self.pCamera:SetPosition(self.pPlayer:GetPosition(true).x, self.pPlayer:GetPosition(true).y-1, self.pPlayer:GetPosition(true).z-1, false ) self.ragdoll = CRagDoll:Create() --self.camera:SetDebugEntityBoxesMode(true) --self.camera:SetDebugPhysicsMode(true) System:Print("System Player create... OK!") end function this:Update() self.pPlayer:SetPosition(self.bNeck:GetPosition(true)) self.camera:SetPosition(self.pCamera:GetPosition(true)) self.camera:SetRotation(self.pCamera:GetRotation(true)) self:Move() if self.ragdoll.r == true then self.pPlayer:SetParent(nil,true) end self:UpdateCamera() self.ragdoll:Update() end function this:UpdateCamera() self.sx = Math:Round(Context:GetCurrent():GetWidth()/2) self.sy = Math:Round(Context:GetCurrent():GetHeight()/2) self.posMouse = Window:GetCurrent():GetMousePosition() Window:GetCurrent():SetMousePosition( self.sx, self.sy ) self.dx = self.posMouse.x - self.sx self.dy = self.posMouse.y - self.sy self.rot = self.pPlayer:GetRotation() if self.rot.x >= 45 then self.rot.x = 45 elseif self.rot.x <= -45 then self.rot.x = -45 end self.rot.y = self.rot.y + self.dx / 50.0 / Time:GetSpeed() self.rot.x = self.rot.x + self.dy / 50.0 / Time:GetSpeed() self.pPlayer:SetRotation(self.rot, true ) end function this:Move() self.vel = 0.0 if Window:GetCurrent():KeyDown(Key.W) then self.vel = 1.0 if Window:GetCurrent():KeyDown(Key.Shift) then self.vel = 2.0 end self.ang = 180 end if Window:GetCurrent():KeyDown(Key.S) then self.vel = 1.0 self.ang = 0.0 end self.player:SetInput(self.pCamera:GetRotation(true).y-self.ang,self.vel) end this:Create() return( this ) end
-
When I use FindEntity to search for a brush on the stage, I get errors when using it in the Update functions of the Scripts. function Script:Start() self.myBox = World:GetCurrent():FindEntity("Box1") end function Script:Update() self.myBox:SetColor(1,0,0) -- Unexpected program shutdown. end The error is not evident if I use property variables. Script.myBox = nil --entity "MyBox" function Script:Start() end function Script:Update() self.myBox:SetColor(1,0,0) -- Not Error. end The error does not occur if I search for a mesh entity imported into leadwerks, or an entity such as light, pivot, camera etc. Only with brushes.
-
I create a box brush on a map, and in a script I put the following code and I have an unexpected closing of Leadwerks. function Script:Start() self.box = World:GetCurrent():FindEntity("Box") end function Script:Update() self.box:Hide() end Any suggestions? The log file is blank, it has nothing in it. It should be noted that this does not happen with an external mesh.
-
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
-
--################################################## --# 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
-
Solved, the correction was made not to look for brushes, because with the brushes is that it presents the error, then change the brushes of the rag doll effect by external meshes. In a first level from the file attached to the entity if it works, but if I use external files with the import command and tables, it does not find them. Is that a bug?
-
The command does not find the entity although I have it in the world.
-
I do not pretend that this tutorial is an absolute truth, it is just how I have learned to do things, very possibly I am wrong, but always willing to learn. When programming, it is extremely necessary to plan what you want to do, a coding project should be divided into blocks, function files. It is like writing a book, by pages, by chapters, I speak of a book of modern times, those books that you can touch and pass its pages with a finger wet in saliva, of course because of the pandemic I think that is a danger to do. Well, it is another thing to make a codification as if we were in the first century of our era writing the history of Egypt on a parchment. What I mean by these two examples of the book and the papyrus is that it is good to break the whole code into parts, as when you create a wall, which is made up of much smaller blocks. Unless you are a machine, you will surely put all the code of the player entity in a single script (scroll), but as I have found it easier and more comfortable to simulate a development environment focused on object programming in Lua Script. And how do I do this, through the use of tables. function Script:Start() end This is the Start function of a file attached to a player entity. Inside it I can put everything I can think of for the player entity, ragdoll effect, movement, hud system for life indicators, oxygen, animations, etc. But I feel more comfortable splitting this into files, let's see an example. import("Scripts/Objects/Player/Classes/CPlayer.lua") function Script:Start() self.player = CPlayer:New() end With the Import command, I link another file called CPlayer ( Player Class ), remember this is a kind of simulation of classes and objects. And in that file I have the following. import("Scripts/Objects/Player/Classes/CRagDoll.lua") CPlayer={} function CPlayer:New() local this={} this.ragDoll = CRagDoll:Start() function this:Start() end this:Start() return( this ) end As you can see, inside that CPlayer file, I import another file called CRagdoll, and the principle is totally the same, I repeat this is the way I have found this is more comfortable for me, possibly you feel better putting everything in one file. What is a class? The best way to understand what a class is, is to think of a cookie mold, from which many cookie objects come out, these objects differ from each other in the flavor of the cookie, its color, its texture. That is to say, from a House class, we can create many houses, where their properties such as color and materials vary a little, making each house different. So let's create a Globe class in Lua Script. CGlobe={} function CGlobe:Start() end That's how simple we create our mock class in Lua, a balloon class, where we create balloon objects. The next step is to define the properties of the balloon object, for example its color. CGlobe={} function CGlobe:New() local this={} this.color = "Red" function this:Create() System:Print("Create Globe... OK!) end this:Create() function this:SetColor(color) this.color = color end function this:GetColor() return ( this.color ) end return ( this ) end At this point I create the constructor of the object, it is simply the New function, which returns me the table this, and this calls the start function, creating a default object of red color. We have two methods or functions, SetColor, to give a new color to the balloon, and one called GetColor to retrieve the color of the balloon It should be noted that by handling this file system, you can have a large number of well-organized "objects" on your project that do something. In this case you can create different balloons of different colors. import("Scripts/Objects/Player/Classes/CGlobe.lua") function Script:Start() self.myGlobeRed = CGlobe:Create() System:Print(self.myGlobeRed:GetColor()) self.myGlobeOrange = CGlobe:Create() self.myGlobeOrange:SetColor("Orange") end This is the idea I want to convey, dividing a project into smaller parts will make your life much easier.
-
The question is, how can I change the center of mass of a body in the physics system?
-
First steps in implementing the ragdoll effect, as I am resuming my project.
-
As a user of it, I want to tell you something. Leadwerks is a tool, and it's great, but you have to know this tool, know its potentials and weaknesses, and get the best out of it. Being a platform with a single target is really very nice, I love it, I've tried Unity, App Game Kit, UDK and I always come back here, because the engine as such is focused on creating video games in a very nice and simple way. Sure, it has its weaknesses, but its potentials are more. So if it's really worth it, the goal is achieved, to create a video game. Translated with www.DeepL.com/Translator (free version)
-
I think that you more than anyone else know how things are going and the experience surely helps you to correct and improve things. It's like the painter, every new work he does is a process of learning new things and correcting previous things in his paintings. Good luck in everything you do.
-
Ragdolls disappearing - General Discussion - Leadwerks Community Something to work on.
-
Hi, I am trying to create a simple ragdoll effect on a column. The idea is to assign to those bones a solid body, which I have referenced in green and red, where each one goes in the respective bone. When I run the program, I move the colored bodies to the position of each bone, and then I add mass to those bodies and tell the bones that their parents are those colored bodies. Everything works partly well. Script.bodyHead = nil --Entity "Body Head" Script.bodyFeet = nil --Entity "Body Feet" function Script:Start() --Column self.boneHead = self.entity:FindChild("Bone1") self.boneFeet = self.entity:FindChild("Bone") self.bodyHead:SetMass(0) self.bodyFeet:SetMass(0) self.r = false end function Script:UpdateWorld() if Window:GetCurrent():KeyHit(Key.R) then if self. r == false then self.bodyHead:SetPosition(self.boneHead:GetPosition(true)) self.bodyFeet:SetPosition(self.boneFeet:GetPosition(true)) self.boneHead:SetParent(self.bodyHead) self.boneFeet:SetParent(self.bodyFeet) self.r = true end end if Window:GetCurrent():KeyHit(Key.T) then if self.r == true then self.bodyHead:SetMass(1.0) self.bodyFeet:SetMass(1.0) end end end The spine body falls in the direction of the force of gravity, since the two bones follow the position of the colored rigid bodies. The problem is that depending on a certain movement of the camera the column disappears. I am grateful for any suggestions. So with that taken care of, I would have to think about joints.
-
Ok, here are my models, the question is how do I make them appear where they should appear?
-
Ok, but how do I download the boxes again and the other models, they don't appear in the links you show me.
-
Seriously, do I have to buy again those models of boxes and the others?
-
Any way to show the product in action in marketing is totally valid. A video showing how the product is used, highlighting its advantages, its workflow, etc. will help more than one to get to know the product better. It is proven that an image accompanied by comments is better in the mind of the interested person than something written.