Jump to content

Recommended Posts

Posted

Thats great Hayden. Something i just figured wasnt quite ready even if its just moving the camera down to a lower level. How might we assign a specific key for this? I think its control in the script when i was looking at it. Id rather it be "C". Ill try to figure that out on my own unless you pass along a secret to us all. BTW, GREAT contributions like this will make the community stronger!

 

lines 592-595 appears to be for setting the crouch button so-

-- Check for crouching
if window:KeyHit(Key.ControlKey) then
 self.crouched = not self.crouched
end

could be made into

-- Check for crouching
if window:KeyHit(Key.C) then
 self.crouched = not self.crouched
end

 

Then it appears as if lines 597 - 618 are the crouch function.?

Asus sabertooth 990FX, AMD FX 9590 , Windows 7 Home Premium 64 Bit, 4 HDD's Western Digital Caviar Black set in Raid 0, 16 GB Crucial Ballistix Elite, Asus Radeon R9 270 X 4GB, Corsair CM750M,

Posted

No Problem, I am glad to help!

lines 592-595 appears to be for setting the crouch button so-

-- Check for crouching

if window:KeyHit(Key.ControlKey) then

self.crouched = not self.crouched

end

 

could be made into

-- Check for crouching

if window:KeyHit(Key.C) then

self.crouched = not self.crouched

end

 

 

 

Yep, that is where you can change the Key that activates/deactivates Crouching. Thanks for pointing that out I am sure others will find that useful.

 

Then it appears as if lines 597 - 618 are the crouch function.?

 

Lines 605-610 are the lines that actually make the camera move to your crouch height and I also changed line 599 from -

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

to -

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

 

to activate the Character Controllers crouching function.

  • Upvote 1

Check out my game Rogue Snowboarding- 

https://haydenmango.itch.io/roguesnowboarding

Posted

Got myself an error. Nothing new for me but I got

attempt to perform arithemetic on field "crouchedheight" (a nil value) line 646

 

if it needs to be broken, let me play with it. I copied and pasted the new section into my FPSPlayer.lua file as there are changes made to mine already. Here is the new part pasted.

-- 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 = ((self:IsCrouched() == 1) and crouchHeight or playerHeight)
newCameraPos = Vec3(playerPos.x, newCameraPos.y ,playerPos.z)

if self.crouched==true then
if newCameraPos.y<playerPos.y + self.crouchedheight then
newCameraPos.y = Math:Curve(playerPos.y + self.crouchedheight, newCameraPos.y, self.camSmoothing)
else
newCameraPos.y = playerPos.y + self.crouchedheight
end
elseif newCameraPos.y<playerPos.y + self.eyeheight then
newCameraPos.y = Math:Curve(playerPos.y + self.eyeheight, newCameraPos.y, self.camSmoothing)
else
newCameraPos.y = playerPos.y + self.eyeheight
end

self.camera:SetPosition(newCameraPos)
end

 

Here is my entire file if interested in looking at it.FPSPlayer.lua

Asus sabertooth 990FX, AMD FX 9590 , Windows 7 Home Premium 64 Bit, 4 HDD's Western Digital Caviar Black set in Raid 0, 16 GB Crucial Ballistix Elite, Asus Radeon R9 270 X 4GB, Corsair CM750M,

Posted

OK, I forgot to add in the top section addition of the file. NOW, it throws an error about:

fpsplayer.lua" : 153 : attempt to index field 'camera' (a nil value)

 

Shouldnt have anythign to do with this right?

Asus sabertooth 990FX, AMD FX 9590 , Windows 7 Home Premium 64 Bit, 4 HDD's Western Digital Caviar Black set in Raid 0, 16 GB Crucial Ballistix Elite, Asus Radeon R9 270 X 4GB, Corsair CM750M,

Posted

I think its the changes from the weapon pick up script since I added a line that stops the creation of the camera since I set one in the scene.

Asus sabertooth 990FX, AMD FX 9590 , Windows 7 Home Premium 64 Bit, 4 HDD's Western Digital Caviar Black set in Raid 0, 16 GB Crucial Ballistix Elite, Asus Radeon R9 270 X 4GB, Corsair CM750M,

Posted

back to the error on

attempt to index field 'camera' (a nil value)

 

Attached the edited file. for me, the line in question is 154

	    self.camera:SetFOV(70)

FPSPlayer.lua

Asus sabertooth 990FX, AMD FX 9590 , Windows 7 Home Premium 64 Bit, 4 HDD's Western Digital Caviar Black set in Raid 0, 16 GB Crucial Ballistix Elite, Asus Radeon R9 270 X 4GB, Corsair CM750M,

Posted

Yep, sure did. . . . :)

I even removed it and replaced it.

 

Sent you a PM and a steam invite

Asus sabertooth 990FX, AMD FX 9590 , Windows 7 Home Premium 64 Bit, 4 HDD's Western Digital Caviar Black set in Raid 0, 16 GB Crucial Ballistix Elite, Asus Radeon R9 270 X 4GB, Corsair CM750M,

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