lxFirebal69xl Posted December 12, 2016 Share Posted December 12, 2016 I'm having an issue with crouching in my game that doesn't allow the player to climb over certain objects. Example: The player can't walk over that if he's crouched, but can walk over it just fine while not crouched. The code as it is allows me to crouch under an obstacle, like vents for example, but I find it funny that I'm having the opposite issue. Here's my crouch script, or the parts that matter. Script.crouched = false Script.crouchheight = 1.2 -- Check for crouching if window:KeyHit(Key.C) then self.crouched = not self.crouched end --With smoothing --Position camera at correct height and playerPosition self.entity:SetInput(self.camRotation.y, playerMovement.z, playerMovement.x, jump , self.crouched, 1.0, 0.5, true) local playerPos = self.entity:GetPosition() local newCameraPos = self.camera:GetPosition() local playerTempHeight = 0 if (self:IsCrouched()) then playerTempHeight = self.crouchHeight + playerPos.y else playerTempHeight = self.playerHeight + playerPos.y end --playerTempHeight = ((self:IsCrouched() == true) and crouchHeight or playerHeight) newCameraPos = Vec3(playerPos.x, newCameraPos.y ,playerPos.z) --With smoothing --CROUCH BEGIN local target_height --determine the height of the camera if self.crouched then target_height = self.crouchheight else target_height = self.eyeheight end --With smoothing --calculate the new camera position if newCameraPos.y<playerPos.y + target_height then newCameraPos.y = Math:Curve(playerPos.y + target_height, newCameraPos.y, self.camSmoothing) else newCameraPos.y = playerPos.y + target_height end --CROUCH END Any clues as to how I could fix this issue? Quote Link to comment Share on other sites More sharing options...
Einlander Posted December 12, 2016 Share Posted December 12, 2016 See the comments on this blog http://www.leadwerks.com/werkspace/blog/120/entry-1575-einlanders-halloween-devlog/ 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.