AtomicHashtag Posted June 1, 2015 Share Posted June 1, 2015 Can someone send me or post a .lua script for the FPSCharacter controller that allows me to crouch? Thanks. Quote Link to comment Share on other sites More sharing options...
macklebee Posted June 1, 2015 Share Posted June 1, 2015 Crouching on the inherent character controller physics container appears to be currently disabled. This means the cylinder used for the character does not change height. But you can still simulate the look of crouching by just setting the height of the camera to a lower position. Granted due the character cylinder not changing height at the moment, you will be unable to actually go under anything that a normal standing character cylinder cannot go under. 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...
reepblue Posted June 1, 2015 Share Posted June 1, 2015 Crouching on the inherent character controller physics container appears to be currently disabled. This means the cylinder used for the character does not change height. But you can still simulate the look of crouching by just setting the height of the camera to a lower position. Granted due the character cylinder not changing height at the moment, you will be unable to actually go under anything that a normal standing character cylinder cannot go under. Again, I made a character that can go under stuff. If you play Vectronic use the 0g and ghost box combo to make a ghost box float around half the player's height, they player will go under it and there is a picker test to tell the player not to get up if they are under an object... Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
nick.ace Posted June 2, 2015 Share Posted June 2, 2015 To the OP, this code should work in FPSPlayer.lua (untested, put in UpdatePhysics()): local window=Window:GetCurrent() --youi may not need this line, check to see if it already exists if window:KeyDown(Key.Control) then self.entity:SetInput(self.entity:GetRotation(true).y,0,0,0,false) end if self.entity:GetCrouched() then self.camera:SetPosition(self.entity:GetPosition()+Vec3(0,2,0)) else self.camera:SetPosition(self.entity:GetPosition()+Vec3(0,1,0)) end Crouching is not disabled, it's just that some people, including me, wanted control over how much the character can crouch. It gets frustrating when you can only crouch to about 2/3 the total height (so vents are impossible and going prone is also impossible). Quote Link to comment Share on other sites More sharing options...
macklebee Posted June 2, 2015 Share Posted June 2, 2015 Previous LE3 versions would alter the character's physics cylinder height which I mistakenly assumed it meant it was disabled. The parameter for crouch in the SetInput() command provides feedback for the entity:GetCrouched() command. And yes, like I mentioned in my previous post, you can still simulate the look of being crouched by moving the camera height. Also, your code above needs to toggle the crouch variable. -- Check for crouching if window:KeyHit(Key.C) then crouched = not crouched end ... ... self.entity:SetInput(self.camRotation.y, playerMovement.z, playerMovement.x, jump , crouched, 1.0, 0.5, true) ... if self.entity:GetCrouched() then self.camera:SetPosition(self.entity:GetPosition()+Vec3(0,1,0)) else self.camera:SetPosition(self.entity:GetPosition()+Vec3(0,2,0)) end Note that you also had the y-value swapped for crouched/not crouched. 1 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...
nick.ace Posted June 2, 2015 Share Posted June 2, 2015 Well, I know crouch works because I've been using it in my project right now (I used it yesterday) to get under smaller regions. I haven't used GetCrouched() to be honest, so maybe that's broken, but the SetInput() works for me (I'm on the beta). Every time you call SetInput(), the crouch reverts back to true by default unless you specify otherwise. Maybe this is what is causing it to not work properly on your end? 2 Quote Link to comment Share on other sites More sharing options...
macklebee Posted June 2, 2015 Share Posted June 2, 2015 Yes you are right - it appears that only the drawing of the physics container is not being modified. Once I saw that I assumed that it was disabled and apparently Josh is under that impression as well since he basically stated as such last night. And GetCrouched() is not broken but you have to use the parameter in the SetInput() command for it to work. Every time you call SetInput(), the crouch reverts back to true by default unless you specify otherwise. Maybe this is what is causing it to not work properly on your end? That is why I said you have to toggle the variable like I showed above. If you want it revert back to 'not crouched' automatically then simply use KeyDown instead of KeyHit. -- Check for crouching crouched = false if window:KeyDown(Key.C) then crouched = true end ... ... self.entity:SetInput(self.camRotation.y, playerMovement.z, playerMovement.x, jump , crouched, 1.0, 0.5, true) 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...
AtomicHashtag Posted June 2, 2015 Author Share Posted June 2, 2015 Thank you everyone 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.