Jump to content

Recommended Posts

Posted

Hello guys. I write ladder script but my script dont work. I go to ladder trigger but script dont work.

 

LADDER CODE

Script.enabled = true
Script.entered = false
Script.collided = false
Script.exited = false

function Script:UpdatePhysics()
if self.enabled then
if self.entered then
if self.collided == false then
System:Print("---TRIGGER")
self.exited = true
self.entered = false
end
end
self.collided = false
end
end

function Script:Collision(entity, position, normal, speed)
if self.enabled then
self.collided = true
if self.entered == false then
if(entity:GetKeyValue("name") == "FPSPlayer") then
self.player = entity
self.player.script.isClimbing = true
self.player:SetGravityMode(false)
System:Print("+++TRIGGER")
self.entered = true
self.exited = false
end
end

end
end

 

FPS PLAYER CODE



...............


Script.health = 100 --float "Health"
Script.maxHealth = 100 --float "Max Health"
Script.mouseSensitivity = 15 --float "Mouse sensitivity"
Script.camSmoothing = 2 --float "Cam smoothing"
Script.moveSpeed = 2.5 --float "Move Speed"
Script.speedMultiplier = 1.5 --float "Run Multiplier"
Script.strafeSpeed = 4 --float "Strafe Speed"
Script.playerHeight = 1.8 --float "Player Height"
Script.jumpForce = 8 --float "Jump Force"
Script.flashlighton = false --bool "Flashlight on"
Script.useDistance = 2
Script.alive=true
Script.eyeheight=1.6
Script.footstepwalkdelay = 500
Script.footsteprundelay = 300
Script.weaponfile=""--path "Weapon" "Prefab (*.pfb):pfb|Prefabs"
Script.input={}
Script.maxcarryweight=5
Script.throwforce = 500
Script.isairborne=false
Script.bloodindex=1
Script.teamid=1--choice "Team" "Neutral,Good,Bad"
Script.hurtoffset=Vec3(0)
Script.smoothedhurtoffset=Vec3(0)
Script.mouseDifference = Vec2(0,0)
Script.playerMovement = Vec3(0,0,0)
Script.tempJumpForce = 0
Script.isClimbing = false
Script.climbSpeed = 2 --float "Climbing Speed"


...............


--Player Movement
local movex=0
local movez=0
self.input[0]=0
self.input[1]=0
if window:KeyDown(Key.W) then self.input[1]=self.input[1]+1 end
if window:KeyDown(Key.S) then self.input[1]=self.input[1]-1 end
if window:KeyDown(Key.D) then self.input[0]=self.input[0]+1 end
if window:KeyDown(Key.A) then self.input[0]=self.input[0]-1 end


local playerMovement = Vec3(0)
if self.isClimbing then
playerMovement.y = self.input[1] * self.climbSpeed
playerMovement.z = self.input[1] * self.climbSpeed

self.entity(0, playerMovement.y, playerMovement.z/10)

else
playerMovement.x = self.input[0] * self.moveSpeed
playerMovement.z = self.input[1] * self.moveSpeed

--This prevents "speed hack" strafing due to lazy programming
if self.input[0]~=0 and self.input[1]~=0 then
playerMovement = playerMovement * 0.70710678
end
--if self.entity:GetAirborne() then
-- playerMovement = playerMovement * 0.2
--end

--Check for running with shift and when not carrying anything
if self.carryingEntity == nil and window:KeyDown(Key.Shift) then
playerMovement.z = playerMovement.z * self.speedMultiplier
end
-- Check for jumping
local jump = 0
if window:KeyHit(Key.Space) and self:IsAirborne() == 0 then
jump = self.jumpForce

self.sound.footsteps.concrete.jump:Play()
if self.weapons[self.currentweaponindex]~=nil then
self.weapons[self.currentweaponindex]:BeginJump()
end
--Give the player an extra boost when jumping
playerMovement = playerMovement * 1.6
end

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

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


end

...............

 

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