#@name ant
@inputs 
@outputs 
@persist Velocity:vector Position:vector Ball:entity
@trigger none


if ( first() ) {
    
    Ball = holoCreate(1, entity():pos(), vec(1))

    function entity:animate( Constant, Damping, Target:vector ) {
        Velocity = Velocity - Constant*(This:pos() - Target)
        Velocity = Velocity*Damping

        holoPos(holoIndex(This), This:pos() + Velocity)
    }
    
    for (I = 2, 6) {
        holoCreate(I)
        if (I > 2) { 
            holoParent(I, I-1)
            holoPos(I, holoEntity(I-1):toWorld(vec(0,0,15)))
        }
        holoModel(I, "models/props_c17/oildrum001.mdl")
        holoScaleUnits(I, vec(1-0.05*I,1-0.05*I,15))
    }
    holoParent(2, entity())

}

interval(60)

Ball:animate(0.25, 0.75, entity():toWorld(vec(0,0,100)))

local LVel = entity():toLocalAxis(Velocity)

local LAng = (ang( -LVel[1], 0, LVel[2] ) / 4):rotateAroundAxis( entity():right(), 15 )
for (I = 2, 6) {
    holoAng(I, holoEntity(I):parent():toWorld( LAng ) )
}
