William's Tool Shead (FPS-RPG) HELP!

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

Make a special type of ground area players can slide on (for example “surfground”), then check to see if the player is colliding with that ground (I’ve forgotten most of my Python at the moment, but if you wrote the code above this’ll be easy, if not, the code above checks for those controls being pressed, it’s the same idea), if so, move them at the speed you wish.

As for control in the air, do you mean like jump and then you can move forward, back etc?

Moving in the air should be easy.
There is probably something in the file that says that the player needs to be colliding with the ground to be able to move and jump, but you can add additional controls or tell it that it doesn’t need to collide with the ground to move. (but it should still need to touch the ground to jump):wink: