@name holotest
@inputs 
@outputs 
@persist Body:entity MoveDir:vector Jump FDir:vector
@trigger none

if (first()) {
    
    Body = holoCreate(1)
    Anim = holoCreate(2)
    
    holoParent(2, 1)
    holoModel(2, "models/sprops/misc/alphanum/alphanum_arrow_b.mdl")
    holoAng(2, Body:toWorld(ang(90,0,0)))
    
    holoAlpha(1, 0)
    
    function number lerp( N0, N1, T ) {
        #return N0*T + N1*(1-T)
        return (1-T)*N0 + T*N1
    }
}

W = owner():keyPressed("up")
A = owner():keyPressed("left")
S = owner():keyPressed("down")
D = owner():keyPressed("right")
Space = owner():keyAttack2()

#MoveDir = mix( MoveDir, Body:toWorldAxis( vec( W - S, A - D, 0 ) ):normalized():setZ(0) * 30, 0.5 )
local MDir = Body:toWorldAxis( vec( W-S, A-D, 0 ) ):normalized():setZ(0) * 5
FDir = mix( MDir, FDir, 0.25 )


local Direction = rangerOffset( Body:pos(), Body:pos() + FDir )
local Height    = rangerOffset( 100, Body:pos(), vec(0, 0, -1) ):pos()
local Movement  = Direction:hit() ? Body:pos() : Direction:pos()


#MDir = entity():toWorldAxis( vec(-FDot, RDot, 0)*50 + vec( (W-S), (A-D), 0 ):normalized()*50 )
#FDir = mix( MDir, FDir, 0.25 )



if (Space & Jump == 1) { Jump = 0 }
if (Jump < 1) { Jump = min(Jump + 0.125, 1) }

holoPos( 1, Movement:setZ(Height:z() + 20 + abs(sin( Jump*180 ))*40) )
holoAng( 1, ang( 0, (owner():eyeTrace():position() - Body:pos()):toAngle():yaw(), 0 ):rotateAroundAxis( vec(0,0,1), (A-D)*-90 ) )


#holoPos( 2, Body:toWorld( vec(0, 0, abs(sin( Jump*180 ))*64 ) ) )

interval(60)
