@name gttest1
@inputs 
@outputs DeltaTime Frames StepRate StepCycle FootFract
@persist CurTime Position:vector Base:entity Frames Foot:vector OldFoot:vector MidFoot:vector FootPos:vector FootLock
@trigger none



if (first()) {
    
    #-------------------------------
    #-- Delta Time function
    
    CurTime = curtime() 
    function deltaTime( Interval ) {
        interval(Interval)

        DeltaTime = curtime() - CurTime
        CurTime = curtime()   
    }

    
    Base = holoCreate(1, entity():pos() + vec(0, 0, 50))
    
    Position = Base:pos()
    Foot = Position
    OldFoot = Foot
    FootPos = Foot
    
    
    holoCreate(2)
    holoColor(2, vec(255, 0, 0))
    holoCreate(3)
    holoColor(3, vec(255, 0, 0))


}

deltaTime(60)

local UnitsPerSecond = 200

local MoveSpeed = DeltaTime*UnitsPerSecond
local MoveDir = vec(MoveSpeed, 0, 0)

Frames += MoveSpeed
Position += MoveDir

holoPos(1, Position)

StepRate = (UnitsPerSecond/1)*DeltaTime
StepCycle = (StepCycle + StepRate ) % UnitsPerSecond


if (!FootLock & StepCycle >= (UnitsPerSecond/1)) {
    FootLock = (UnitsPerSecond/1)
    OldFoot = FootPos
    Foot = Position + MoveDir:normalized()*100 + Base:right()*20 
    MidFoot = (OldFoot + Foot)/2 + vec(0, 0, OldFoot:distance(Foot)/3)
}
FootLock = max(FootLock - StepRate, 0)
FootFract = 1 - FootLock / (UnitsPerSecond/1)

FootPos = bezier(OldFoot, MidFoot, Foot, FootFract)

holoPos(3, Foot)
holoPos(2, FootPos)

#holoPos(2, Position + Base:right()*20 + Base:forward()*sin(Frames)*30)
#holoPos(3, Position - Base:right()*20 + Base:forward()*sin(Frames+180)*30)
