Animation and Sound

I use the cont.activate() method to play sounds and animations. It doesn’t really work though. The animation won’t stop playing and the sound can’t go faster than the .wav’s length. What is a good way to do those two things and have them work correctly?

And while I am at it, how would I make this (code below) do diagonal movement. I was hoping there is a way other than creating 4 more ifs for each key combo.

    if onGround.positive:
        if wKey:
            player.setLinearVelocity((0, speed, 0), True)
        elif sKey:
            player.setLinearVelocity((0, -speed, 0), True)
        if dKey:
            player.setLinearVelocity((speed, 0, 0), True)
        elif aKey:
            player.setLinearVelocity((-speed, 0, 0), True) 


You may need to use cont.deactivate to stop your animations. Not sure about syncing the wav file with your animations.

As for movement:

fwd = cont.sensors["W"]
back = cont.sensors["S"]
slft = cont.sensors["A"]
srght = cont.sensors["D"]
act = cont.actuators["floormove"]
speed = 2

if (fwd.positive or back.positive) and not (slft.positive or srght.positive):
if (slft.positive or srght.positive) and not (fwd.positive or back.positive):
if (fwd.positive or back.positive) and (slft.positive or srght.positive): #Here is diagonal movement

fspeed = speed * (fwd.positive - back.positive) #fspeed, or forward speed, takes the walking/running/crouch speed and multiplies it by W key and S key pressure to equal our forward/backward speed
sspeed = speed * (srght.positive - slft.positive) #sspeed or sidways speed, takes the walking/running/crouch speed and multiplies it by A key and D key pressure to equal our right/left speed

act.linV = [-fspeed, sspeed, jspeed]

i guess , for the sound .

check the current frame(float) , then , if the current frame is > of X : stop sound.

fr = act.frame #if you use the actuator
if fr > 50:

this method anyway work better with a big action , where start/end loop is already written somewhere.

otherwise : the sensor actuator ? not work?