==June 15 2009: 00:45================================================
Hi. I’m trying to work on the FPS template:
http://blenderartists.org/forum/showthread.php?t=85219
Right now I need help in getting the player to surf, like in CS:S or TF2.
I made some fast changes like allowing the player to run really fast when holding shit instead of being stealthy.
I just don’t know what to do about the physics. How do I make the player slide on a 45 degree angle when the player is walking into it. For that matter how do I make the player have control in the air?
This is the code I’m looking at the most right now
#==========================================
#This script Governs the Players movment.
#
#==========================================
cont = GameLogic.getCurrentController()
own = cont.getOwner()
g1 = cont.getSensor("playerGround1").isPositive()
g2 = cont.getSensor("playerGround2").isPositive()
g3 = cont.getSensor("playerGround3").isPositive()
g4 = cont.getSensor("playerGround4").isPositive()
jump = cont.getSensor("Space")
fwd = cont.getSensor("W")
back = cont.getSensor("S")
slft = cont.getSensor("A")
srght = cont.getSensor("D")
shift = cont.getSensor("shift")
lctrl = cont.getSensor("lctrl")
act = cont.getActuator("floormove")
crouch = cont.getActuator("crouch")
idle = cont.getActuator("idle") #gun anim ipo
run = cont.getActuator("run") #gun anim ipo
ownc = crouch.getOwner()
speed = 6
jspeed = 0
sqrt2over2 = 0.70710678
# Checks to make sure player is on the ground by use of Empties.
if g1 or g2 or g3 or g4:
if lctrl.isPositive():
speed = 2
if ownc.frame < 20:
ownc.frame += 1
GameLogic.addActiveActuator(crouch, 1)
if not lctrl.isPositive() and ownc.frame > 1:
ownc.frame -= 1
GameLogic.addActiveActuator(crouch, 1)
else:
GameLogic.addActiveActuator(crouch, 0)
if shift.isPositive():
speed = speed + 18
fspeed = speed * (fwd.isPositive() - back.isPositive())
sspeed = speed * (srght.isPositive() - slft.isPositive())
#Makes sure that pressing two keys dose not duble speed.
if fspeed and sspeed:
fspeed *= sqrt2over2
sspeed *= sqrt2over2
if not jump.isPositive():
own.jstate = 1
#Allows the player to jump.
if jump.isPositive() and own.jstate == 1:
jspeed = speed
own.jstate = 0
act.setLinearVelocity(sspeed, fspeed, jspeed, 1)
if [sspeed, fspeed, jspeed] == [0, 0, 0]:
GameLogic.addActiveActuator(idle, 1)
GameLogic.addActiveActuator(run, 0)
GameLogic.addActiveActuator(act, 0)
else:
if (lctrl.isPositive() + shift.isPositive() + jspeed) == 0:
GameLogic.addActiveActuator(idle, 0)
GameLogic.addActiveActuator(run, 1)
else:
GameLogic.addActiveActuator(idle, 1)
GameLogic.addActiveActuator(run, 0)
GameLogic.addActiveActuator(act, 1)
#everytheing else
else:
GameLogic.addActiveActuator(act, 0)
own.rel = 1