PerEspen00 Posted August 20, 2016 Share Posted August 20, 2016 So I'm trying to make my character be able to go through vents which are tight spaces. I tried just making my own crouch function which lowers the camera and the hitbox, which didn't work. So there must be some hidden collision going on. Anyway, I'm using a custom player script, but it has similarities with the standard FPS controller. So my question is: Is there any hidden collision going on with the character controller? And is there anyway to change the collision with it? Quote Link to comment Share on other sites More sharing options...
reaper2259 Posted August 20, 2016 Share Posted August 20, 2016 So I'm trying to make my character be able to go through vents which are tight spaces. I tried just making my own crouch function which lowers the camera and the hitbox, which didn't work. So there must be some hidden collision going on. Anyway, I'm using a custom player script, but it has similarities with the standard FPS controller. So my question is: Is there any hidden collision going on with the character controller? And is there anyway to change the collision with it? i could be wrong but i think resizing the character controller is not possible or bugged because i have tried before with no such luck which makes things annoying. Quote Link to comment Share on other sites More sharing options...
macklebee Posted August 20, 2016 Share Posted August 20, 2016 It is possible and crouch does work but there are some caveats. It appears crouch height is 1.2 meters and the debug physics body does not change size at least visually when crouched. example: window = Window:Create("crouch height",0,0,800,600) 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("Crouched: "..tostring(crouch),2,2) context:SetBlendMode(Blend.Solid) context:Sync() end 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... 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...
PerEspen00 Posted August 20, 2016 Author Share Posted August 20, 2016 There is some issue with running your code, probarly just me being oblivious Anyway, so i basically made is so when the player is crouched some things, like vent roofs and such have no collision. And made a pick operation to see if anything was above you so you cant get up, but when they get out of the vent they go flying out of it. Which is kinda a issue Quote Link to comment Share on other sites More sharing options...
macklebee Posted August 20, 2016 Share Posted August 20, 2016 There is some issue with running your code, probarly just me being oblivious not quite sure what the issue is as that code has worked and works now for me. 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...
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.