@name anim2test
@inputs 
@outputs BaseSpeed MaxSpeed Acceleration Integ
@persist 
@trigger 

if (first()) {
    
    #include "anim/libraries/animate2"
    
    createBase(1)
    
    local SL = 25
    local SH = 25

    addFoot("1", vec(40,15,0), 0, SL, SH, 3)
    addFoot("2", vec(40,-15,0), 45, SL, SH, 3)
    addFoot("3", vec(-40,15,0), 180, SL, SH, 3)
    addFoot("4", vec(-40,-15,0), 225, SL, SH, 3)
}

dt(60)

Player = owner()
MaxSpeed = fromUnit( "mph", 15)
Acceleration = MaxSpeed*2

local AimDir = vec(1,0,0)
local SideDir = AimDir:cross(vec(0, 0, 1))
local Forward = Player:keyPressed("up") - Player:keyPressed("down")
local Strafe  = Player:keyPressed("left") - Player:keyPressed("right")

if (Forward | Strafe) {
    BaseSpeed = min(BaseSpeed + Acceleration*DeltaTime, MaxSpeed)    
}
else {
    BaseSpeed = max(BaseSpeed - Acceleration*DeltaTime, 0)
}

BasePos += AimDir*BaseSpeed*DeltaTime
Integ += BaseSpeed*DeltaTime


holoPos(BaseIndex, toWorld(vec(0, 0, 40 + abs(cos(Integ/2)*25*(BaseSpeed/MaxSpeed))), ang(), BasePos, BaseAng))
holoAng(BaseIndex, toWorldAng(vec(), ang(sin(-Integ)*25*(BaseSpeed/MaxSpeed),0,0), BasePos, BaseAng))

#holoPos(BaseIndex, toWorld(vec(0, 0, 40 + abs(cos(Integ)*50*(BaseSpeed/MaxSpeed))), ang(), BasePos, BaseAng))
#holoAng(BaseIndex, toWorldAng(vec(), ang(sin(-Integ*2)*50*(BaseSpeed/MaxSpeed),0,0), BasePos, BaseAng))

updateFeet(1)


