_Assassin_ Posted August 23, 2017 Share Posted August 23, 2017 I just recently got into development with the Leadwerks engine and am interested in developing a project from the First-Person perspective. As I am new to Lua and an inexperienced programmer (programmed some office-based applications in VB.NET) I am unsure how to get started. The only tutorials I can find specifically on the scripting of a character controller is over 6 years old. In short: What are the very basic requirements for creating a simple character controller? Quote Link to comment Share on other sites More sharing options...
Solution AggrorJorn Posted August 23, 2017 Solution Share Posted August 23, 2017 This API command comes with a complete sample on how to set up a basic character controller. https://www.leadwerks.com/learn?page=API-Reference_Object_Entity_SetInput Alternatively you can look at or use the FirstPerson script. This script is located in the scripts folder in any project which uses the game template "FirstPersonShooter" 1 Quote Link to comment Share on other sites More sharing options...
_Assassin_ Posted August 23, 2017 Author Share Posted August 23, 2017 Thanks for pointing out the FPSController script. Managed to write a basic script using that as a reference. Quote Link to comment Share on other sites More sharing options...
DooMAGE Posted August 23, 2017 Share Posted August 23, 2017 Only if the FPSController script had crouch too :/ Quote My Leadwerks games! https://ragingmages.itch.io/ Link to comment Share on other sites More sharing options...
_Assassin_ Posted August 24, 2017 Author Share Posted August 24, 2017 12 hours ago, DoomSlayer said: Only if the FPSController script had crouch too :/ Their is references to crouching in the default FPS script but I could never get it to work myself. It would be helpful to see how crouching would be implemented in Lua so I can recreate something like it in my script. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted August 24, 2017 Share Posted August 24, 2017 It is currently not support. The flag for crouching can be set but doesn't do anything. The documentation states that this flag only exists for future updates. Quote Link to comment Share on other sites More sharing options...
_Assassin_ Posted August 24, 2017 Author Share Posted August 24, 2017 Strange, you would think a 3D game engine for the development of first person and third person games would have something as fundamental as support for crouching. Not that I'm complaining or anything as that is way above my technical level anyway xD. You could emulate some sort of crouching mechanic by moving the camera I suppose, as long as you were using the first person perspective and made the player model invisible that is. Not a very smart way to do it I know, but you could at the very least make it look like you are crouching but very little else. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted August 24, 2017 Share Posted August 24, 2017 I have used crouching with the default character controller for many years and this was officially supported. I don't know how long it has been since this option was removed. Leadwerks did recently switch to a new version of the Newton dynamics physics engine, which migh have something to do with it. Other than that, there are some issues with the current character controller which are pain to work with. Search for topics with 'Side scroller' and you will find plenty. Quote Link to comment Share on other sites More sharing options...
_Assassin_ Posted August 24, 2017 Author Share Posted August 24, 2017 So is making a fully-featured first person game still possible in the engines current state? I have concerns about what I want to achieve may not be possible with this engine. Are their any other features that have been removed after the physics engine has been updated? Quote Link to comment Share on other sites More sharing options...
_Assassin_ Posted August 25, 2017 Author Share Posted August 25, 2017 That's okay I can wait. It's not like I'll know how to implement it properly anyway. I only just managed to work out how to stop my character controller from being able to jump infinitely. xD Quote Link to comment Share on other sites More sharing options...
macklebee Posted August 25, 2017 Share Posted August 25, 2017 On 8/24/2017 at 9:00 AM, jen said: Crouching works on 4.3. You'll have to wait for an update if you want to use Character Controller Crouch in later versions. Crouching works the same in 4.4 as it has for a couple of years and several versions with some caveats and unfortunately it is not an officially supported feature (and hasn't been since the LE2 days). The crouch height is 1.2 meters and the debug physics body does not change size at least visually when crouched, but you will be able to move a character controller under anything taller than 1.2 meters. Also note this example shows that when crouching under something, the developer needs to prevent standing back up to prevent weird physic results from occurring - ie character slingshot across map, character pushed through the map, etc... window = Window:Create("crouch height",0,0,800,600,Window.Titlebar+Window.Center) context = Context:Create(window) world = World:Create() camera = Camera:Create() camera:SetRotation(40,0,0) camera:Move(0,0,-8) light = DirectionalLight:Create() light:SetRotation(35,35,0) camera:SetDebugPhysicsMode(true) ground = Model:Box(10,1,10) ground:SetPosition(0,-0.5,0) ground:SetColor(0,1,0) shape = Shape:Box(0,0,0, 0,0,0, 10,1,10) ground:SetShape(shape) shape:Release() box1 = Model:Box(1,1.2,1) box1:SetPosition(-2,0.6,-1) box2 = Model:Box(1,1.2,1) box2:SetPosition(2,0.6,-1) box3 = Model:Box(5,1,1) box3:SetPosition(0,1.7,-1) shape = Shape:PolyMesh((box1:GetSurface(0))) box1:SetShape(shape) shape = Shape:PolyMesh((box2:GetSurface(0))) box2:SetShape(shape) shape = Shape:PolyMesh((box3:GetSurface(0))) box3:SetShape(shape) shape:Release() player = Pivot:Create() visiblecapsule = Model:Cylinder(16,player) visiblecapsule:SetScale(.8,1.8,.8) visiblecapsule:SetPosition(0,.9,0) player:SetPosition(-4,0,0) player:SetMass(1) player:SetPhysicsMode(Entity.CharacterPhysics) crouch = false while window:KeyHit(Key.Escape)==false do if window:Closed() then break end move = ((window:KeyDown(Key.W) and 1 or 0) - (window:KeyDown(Key.S) and 1 or 0))*4 strafe = ((window:KeyDown(Key.D)and 1 or 0) - (window:KeyDown(Key.A) and 1 or 0))*4 jump = (window:KeyHit(Key.Space) and 1 or 0)*8 if window:KeyHit(Key.C) then crouch = not crouch end player:SetInput(0,move,strafe,jump,crouch) Time:Update() world:Update() world:Render() context:SetBlendMode(Blend.Alpha) context:DrawText("Press WSAD to move and C to toggle crouch",2,2) context:DrawText("Crouched: "..tostring(crouch),2,22) context:SetBlendMode(Blend.Solid) context:Sync(true) end 1 4 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
cassius Posted August 27, 2017 Share Posted August 27, 2017 Crouch works fine in my c++ project. The project pre-dates le 4.4 but I have updated it with no problems. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
_Assassin_ Posted August 28, 2017 Author Share Posted August 28, 2017 Nice work around, I was under the assumption that it wasn't possible since the support was dropped. Managed to implement something similar in my project using this as a reference. Thank you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.