Hello there, this is my first thread and i am still fairly new to gmod lua and would still like to learn more.
Please understand if i'm a scrub and i don't know what i'm talking about but I need some help on making a
wall kick/parkour function for my server that i'm making.
(Edit) If any of you are familiar to the server Art of Parkour or Extended Movement Mod I am trying to make something similar :)
What are your doubts
I was just messing around with my old parkour system, here's a simplified example of it :
[code]
function GM:Move( ply, mv )
-- If Jump is pressed, and player not on the ground then
if ply:KeyPressed( IN_JUMP ) && !ply:OnGround() then
--Setup Variables
local tracedata = {}
local trace = nil
tracedata.start = ply:GetPos() --the position of the player (located at their base)
tracedata.filter = ply --ignore the player in the trace
--trace in the direction the player is facing to see if they're close to a wall
tracedata.endpos = ply:GetPos()+(ply:GetAngles():Forward()*45)
trace = util.TraceLine(tracedata)
-- We do a second trace 40 units up from the players base aswell for better detection
tracedata.start = ply:GetPos() + Vector(0,0,40)
local trace2 = util.TraceLine(tracedata)
-- if either of the traces hit's a wall
if trace.HitWorld || trace2.HitWorld then
--give the player a boost up
ply:SetVelocity(Vector(0,0,20000))
-- play a nice sound
ply:EmitSound( "physics/concrete/concrete_impact_hard"..math.random(3)..".wav", 80, math.random(70,90) )
end
end
end
[/code]
This runs server side in a Gamemode.
From here you can try improving upon it with logic to make it a bit more 'balanced'.
Examples of things you could add are: Delays between each jump, a back kick when the player is holding the IN_BACK key to push them away from the wall, Side jumps, double jumps in the air if they're not near a wall.
Hope this helps you get started :)
Oh wow thank you i will have to mess around with this, thank you meka :)
[editline]18th May 2017[/editline]
What if i wanted to have it be specific to which side of the wall they are facing, aka if the wall is to their right or left
here is what i changed
[CODE]if ply:KeyDown( IN_JUMP, IN_MOVELEFT ) && ply:KeyPressed( IN_MOVERIGHT, IN_FORWARD) && !ply:OnGround() then[/CODE]
So for example if the wall is on their left they would have to spam w,d if its on their right it would be w, a
KeyDown/KeyPressed does not take multiple arguments. You have to check each individually.
Sorry, you need to Log In to post a reply to this thread.