Jump to content

Recommended Posts

Posted

Seriously, I have the crouch "working", it's just I can't go under objects.

How low are the objects that you are trying to crouch under? If its lower than 0.8 or 0.9 meters then you will not be able.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Posted

You need to set the input for crouch. See below. I'm not sure why it wasn't included in the tutorial.

 

self.entity:SetInput(self.camRotation.y, playerMovement.z, playerMovement.x, jump , self.crouched, 1.0, 0.5, true)

  • Upvote 2
Posted

Since I had not tackled this yet, I decided to this morning. ( Not adding the Peek, but only the crouch option) Brutile method seems to let the player crouch to pass below surfaces previously not able.

SpEcIeS

Posted

Replaced the false with self.crouched in the UpdatePhysics function? If so, maybe it is what macklebee was saying about the height.

 

--With smoothing 
--Position camera at correct height and playerPosition
--self.entity:SetInput(self.camRotation.y, playerMovement.z, playerMovement.x, jump , false, 1.0, 0.5, true)
self.entity:SetInput(self.camRotation.y, playerMovement.z, playerMovement.x, jump , self.crouched, 1.0, 0.5, true)

  • Upvote 1

SpEcIeS

Posted

The crouch height is 1.2 meters (I must have been remembering old heights typically used with LE2). What may be confusing about the crouch is that the visible debug physics body does not change size when crouch is true.

 

Example script that shows the crouch height of 1.2 meters. Use WSAD to move and hit C to crouch:

window = Window:Create("crouch height",0,0,800,600,17)

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...

  • Upvote 2

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...