Jump to content

YouGroove

Members
  • Posts

    4,978
  • Joined

  • Last visited

Everything posted by YouGroove

  1. Hi Goodjourney, You can use this script as a working base for a TPS http://www.leadwerks.com/werkspace/topic/12672-tps-movement-tutorial/
  2. RPG is heavy UI and LE3 don't have out of the box UI, i'm not sure this is the best game template for any new comer to LE3.
  3. Simple and basic smooth TPS code, based on Rick's game and enhanced to have smooth movement. Enjoy import "Scripts/AnimationManager.lua" Script.Camera = "" --entity Script.cameraOffsetZ= -7 --float Script.cameraOffsetY= 3 --float function Script:Start() --self.btnExit = Button:Create("Exit", 0, 0, 100, 50, self, self.btnExit_Click) self.playerMovement = Vec3(0,0,0) self.cameraYaw = 0 self.cameraPitch = 10 self.dx = 0 self.dy = 0 self.mousePos = 100 self.moveSpeed = 10 self.baseAnimMgr = AnimationManager:Create(self.entity) self.entity:SetKeyValue("type", "player") self.state="idle" self.attackName="" end function Script:UpdateWorld() self.entity:SetRotation(0,180,0,true) self:Movement() self:CameraRotation() self:Animations() end function Script:attackEnd() self.state="idle" end function Script:CameraRotation() -- rotate yaw and tell the player about it so the character can use it in SetInput() local mpos = App.window:GetMousePosition() self.dx = Math:Curve((mpos.x - self.mousePos) / 10.0, self.dx, 3.0 / Time:GetSpeed()) self.cameraYaw = self.cameraYaw + self.dx -- rotate pitch self.dy = Math:Curve((mpos.y - self.mousePos) / 10.0, self.dy, 3.0 / Time:GetSpeed()) local pitch = self.cameraPitch + self.dy if pitch > -25 and pitch < 55 then self.cameraPitch = pitch end -- reset the mouse position App.window:SetMousePosition(self.mousePos, self.mousePos) end function Script:Movement() -- handle player movement self.playerMovement.z = ((App.window:KeyDown(Key.W) and 1 or 0) - (App.window:KeyDown(Key.S)and 1 or 0)) * self.moveSpeed --self.playerMovement.x = ((App.window:KeyDown(Key.D) and 1 or 0) - (App.window:KeyDown(Key.A)and 1 or 0)) * Time:GetSpeed() * self.moveSpeed if self.state=="attack" then self.playerMovement.z=0 end if self.playerMovement.z > 0 and self.state~="attack" then self.state="walk" end if self.playerMovement.z == 0 and self.state~="attack" then self.state="idle" end -- move the camera to the player and set the yaw from 3rd person view self.Camera:SetPosition(self.entity:GetPosition(true), true) self.Camera:SetRotation(Vec3(self.cameraPitch, self.cameraYaw, 0), true) -- offset the camera up and back self.Camera:Move(0, self.cameraOffsetY, self.cameraOffsetZ) -- rotate the model along with the camera self.entity:SetRotation(Vec3(0, self.cameraYaw +180, 0)) -- move the controller in the rotation of the player self.entity:SetInput(self.cameraYaw, self.playerMovement.z, 0 --[[self.playerMovement.x]], 0, false, 1) if App.window:MouseHit(1) and self.state~="attack" then self.state="attack" self.baseAnimMgr:SetAnimationSequence("attack", 0.01, 50,1,self,self.attackEnd) end end function Script:Animations() if self.state=="idle" and self.state~="attack" then self.baseAnimMgr:SetAnimationSequence("idle", 0.005, 200) end if self.state=="walk" and self.state~="attack" then self.baseAnimMgr:SetAnimationSequence("walk", 0.01, 200) end end function Script:Draw() -- the order we put these in matters! self.baseAnimMgr:Update() end All movement is in UpdateWorld() because you'll get smoothed physic movement instead of jittering one.
  4. When i want fun robot modeling i just dive in Droid planet. More mechanic design , less cynbernetic : - Slow movement and slow turning speed - 4 auto Guided missiles - 2 main heavy damage guns - Termal vision : no visibility hidding possible - Two special attacks Variation
  5. FBX model to import and test added. treePack.zip
  6. Radeon chips runs always faster then Intel integrated chips on laptops, you have switchable graphics option in Catalyst software menu. Can you tell running what game demo ? And the resolution and quality setting ? Make sure LE3 software runs on the Radeon using catalyst menu and looking at switchable graphics option. On my laptop = Radeon HD 7600M , running LE3 FPS demo (AI and Events) i got 25-30 fps. So your AMD Radeon HD 8400, should run with even better frame rate then mine
  7. YouGroove

    What's Next

    Yes, i remeber testing with physic barrels and doing that only the barrels moved away, the player was still in Z=0. On the other side you will need some raycast checks or use collision function detection to stop moving the character when he touches some static physic box or he can go throught it using PhysicsSetPosition().
  8. Some points after testing it : - 2.5D is not possible in LE3 as collisions will make the character move in Z axis ( or is the script for 2D sprites without 3D collisions ?) - I changed the values for the parameters of the camera and it has no effect, the camera is still very far from character. - Giving a script without explaining how to use camera parameters and their effect is not very usefull.
  9. I have LE3 Steam Lua edition that auto updates automatically, som i'm up to date.
  10. EDIT. I found i have same stutterings in my PC with any game whatever is the 3D card, so this is not related to LE3. For now i use Vsync on in the 3D cart settings , and Vsync on in LE3, to have a constant 60 fps in LE3 now with no stutterings. The thread can be closed.
  11. Yes you are right Josh. It was not LE3 bug , but only my bug Removing the game speed and the character keeps a constant movement without any lag. BUT No post effects and changing Quality = 2 , there is small lags , not important , but noticeable (running on GTX 960). I would expect a linear slow down,like games where you put high graphic options the game physics just slow down as much as the graphics , but we don't see some sudden deceleration and some acceleration after. I changed the code to capture the minimum fps, and many times it falls down from 200fps to 30fps
  12. Hi, I submit that as bug because the physics just lags when you keep running forward after a certain time. I have a running example, just press forward to reach the big green cube for in front of the player for example or just always keep running don't stop, and you'll see physics decelerating than accelerating a lot. How to test : -Dezip and put forlder "custom" at the root directory of your project -Put the map file in your map directory -run the game -keep running forward during 30 seconds or more. voxels.zip
  13. Hi, It's trange i updated "My Game", then running it it uses default 1024*768, i got the frame rate able to drop to 30 fps many times like before. I just upgraded to a new GTX 960 for the desktop, i can't image to have such frame rate drop in a simple level. Does someone has the same problem ?
  14. @macklebee : This is another problem not related to constant frame rate and VSync. This is lag not Vsync dropping the frame rate. Demo included, how to test : -Dezip map file in your map directiry - move 3dPerson.lua script to your "Scripts/Objects" directory - launch the game. How to have lag : -move the character forward and click many times on left click (it calls attack function even if animations are not visible and playing); clicking many times and keeping moving forward you'll notice physic lags like character slowing down then a quick accelerations. This means no way to go for TPS games in LE3 on my side with that issue. --------------------- Character collision physics has some core issues, if you put by code the camera FPS behind the player and make the model visible you will see physics jerking a lot. I think this lag is related to the character controller. lag.zip
  15. I runned two projects in my desktop PC, i have the same problem on both : The games runs 60 Fps and each 3 seconds physics start to not respond and FPS drops to 10Fps, then FPs jumps up again to 60Fps, and same loop. I tested with Vsync off, in my Sci Fi project and teh simple Voxel project, with firewall deactivated. Does anyone experienced same issues ? (games just runs fines on the desktop)
  16. Bood. I will give it a try. The link about collision table no more exists http://www.leadwerks.com/werkspace/page/documentation/_/user-guide/scene-browser-r675 A complete documentation about collision set up and responses is really missing in LE3, not only some code example, but a detailled documentation.
  17. This is the way i will go. The question is not how, but more it is possible : To have a physic volume not physically colliding with other physic objects, but still able to trigger a collision when it overlaps the other physic objects or scene objects ?
  18. I run my game at 60 Fps with Quality = 1, but shadows are really only near the character and no more visible in some small distance away Changing quality to 2 and the frame rate drops to 26 Fps Shadows are the main factor, as they will appear in bigger distance. It would be usefull to have a optionnal shadowing technique able to perform faster, perhaps more approximative, but faster when we display distant shadows. (something similar to Anti Aliasing like MSAA that costs power and the alternative FXAA lot more light and producing good results) Thanks.
  19. Some trees polygons are out of the cylinder.
  20. It is possible in LE3 to have Overlapping collision detection without collision reaction ? I mean you make some collision cube with a script. This cube is attached to some character hand. At any time when the cube overlaps any other collision volume like scene objects or other characters , it's script will fire the collision detection function, but the cube don't react to physics.
  21. Some TPS working camera example for you. Remove all uneeded code import "Scripts/AnimationManager.lua" Script.Camera = "" --entity Script.teamid=1 function Script:Start() --self.btnExit = Button:Create("Exit", 0, 0, 100, 50, self, self.btnExit_Click) self.playerMovement = Vec3(0,0,0) self.cameraYaw = 0 self.cameraPitch = 10 self.dx = 0 self.dy = 0 self.mousePos = 100 self.trapMode = false self.stars = 0 self.shooting = false self.moveSpeed = 10 self.fireRate = 500 self.lastFireRate = 0 self.alive = true self.dyingAnimationComplete = false -- 2 "layers" of animations. the base layer and the upper body layer self.baseAnimMgr = AnimationManager:Create(self.entity) self.entity:SetKeyValue("type", "player") self.state="idle" self.attackName="" self.pick = PickInfo() self.entity:SetPickMode(0,true) end function Script:UpdateWorld() if self.alive == false then return end self.entity:SetRotation(0,180,0,true) self:Movement() self:CameraRotation() self:Animations() end function Script:attackEnd() self.state="idle" end function Script:CameraRotation() -- rotate yaw and tell the player about it so the character can use it in SetInput() local mpos = App.window:GetMousePosition() self.dx = Math:Curve((mpos.x - self.mousePos) / 10.0, self.dx, 3.0 / Time:GetSpeed()) self.cameraYaw = self.cameraYaw + self.dx -- rotate pitch self.dy = Math:Curve((mpos.y - self.mousePos) / 10.0, self.dy, 3.0 / Time:GetSpeed()) local pitch = self.cameraPitch + self.dy if pitch > -25 and pitch < 55 then self.cameraPitch = pitch end -- reset the mouse position App.window:SetMousePosition(self.mousePos, self.mousePos) end function Script:Movement() -- handle player movement self.playerMovement.z = ((App.window:KeyDown(Key.W) and 1 or 0) - (App.window:KeyDown(Key.S)and 1 or 0)) * Time:GetSpeed() * self.moveSpeed --self.playerMovement.x = ((App.window:KeyDown(Key.D) and 1 or 0) - (App.window:KeyDown(Key.A)and 1 or 0)) * Time:GetSpeed() * self.moveSpeed if self.state=="attack" then self.playerMovement.z=0 end -- reduce speed when moving backwards --if self.playerMovement.z < 0 then --self.playerMovement.z = self.playerMovement.z --end if self.playerMovement.z > 0 and self.state~="attack" then self.state="walk" end if self.playerMovement.z == 0 and self.state~="attack" then self.state="idle" end -- move the camera to the player and set the yaw from 3rd person view self.Camera:SetPosition(self.entity:GetPosition(true), true) self.Camera:SetRotation(Vec3(self.cameraPitch, self.cameraYaw, 0), true) -- offset the camera up and back self.Camera:Move(0, 5, -15) -- rotate the model along with the camera self.entity:SetRotation(Vec3(0, self.cameraYaw +180, 0)) -- move the controller in the rotation of the player self.entity:SetInput(self.cameraYaw, self.playerMovement.z, 0 --[[self.playerMovement.x]], 0, false, 1) if App.window:MouseHit(1) and self.state~="attack" then self.state="attack" self.baseAnimMgr:SetAnimationSequence("attack", 0.01, 50,1,self,self.attackEnd) end end function Script:Animations() -- consider base animations here if self.state=="idle" and self.state~="attack" then self.baseAnimMgr:SetAnimationSequence("idle", 0.005, 200) end if self.state=="walk" and self.state~="attack" then self.baseAnimMgr:SetAnimationSequence("walk", 0.01, 200) end end function Script:UpdatePhysics() end function Script:Draw() -- the order we put these in matters! self.baseAnimMgr:Update() end function Script:PostRender(context) end function Script:Delete() end
  22. Recalculating normals treshold should fix it using flat surfaces instead of smoothing groups.
  23. Do you use a PC or a phone when your browse LE3 forums ? To have the icons list you just need to click on the smiley on top and it will display the smileys list. We could ask some new LE3 tutorial about smileys if you need it
  24. Got it working without using matrix. self.sword = Model:Load("Models/sword.mdl") local child=self.entity:FindChild("Bone_002_R_002"); if (child) then self.sword:SetParent(child); local pos = child:GetPosition(true) pos.z = pos.z + 1 pos.x = pos.x - 0.5 self.sword:SetPosition(pos,true); local rot = child:GetRotation(true) self.sword:SetRotation(rot,true); end
×
×
  • Create New...