@name Ragdoll Follower
@outputs
@persist Time X Y Z
@trigger all

interval(10)

Time++
E = entity():isWeldedTo()
if(E:pos():distance(owner():pos()) > 100)
{
    X += cos(E:bearing(owner():pos()))*(E:pos():distance(owner():pos())/25)
    Y += sin(-E:bearing(owner():pos()))*(E:pos():distance(owner():pos())/25)
    Z += E:elevation(owner():pos())
}
else
{
}
B = E:bearing(owner():pos())
O = vec(X,Y,owner():pos():z())

if(first())
{
    X = E:pos():x()
    Y = E:pos():y()
    holoCreate(0)
    holoParent(0,E)
    holoScale(0,vec(0,0,0))
}

holoAng(0,E:angles():setYaw(-B))
holoPos(0,E:pos())
A = holoEntity(0)

Head = E:bone(10)
Ass = E:bone(0)
Torso = E:bone(1)

RArm1 = E:bone(2)
RArm2 = E:bone(6)
RArm3 = E:bone(7)

LArm1 = E:bone(3)
LArm2 = E:bone(4)
LArm3 = E:bone(5)

RLeg1 = E:bone(8)
RLeg2 = E:bone(9)
RLeg3 = E:bone(14)

LLeg1 = E:bone(11)
LLeg2 = E:bone(12)
LLeg3 = E:bone(13)


Head:applyForce(((O+A:up()*80-Head:pos())*10-Head:vel())*Head:mass())
Ass:applyForce(((O+A:up()*42-Ass:pos())*10-Ass:vel())*Ass:mass())
Torso:applyForce(((O+A:up()*52-Torso:pos())*10-Torso:vel())*Torso:mass())
RArm3:applyForce(((O+A:up()*10+A:right()*10-RArm3:pos())*10-RArm3:vel())*RArm3:mass())
LArm3:applyForce(((O+A:up()*10+A:right()*-10-LArm3:pos())*10-LArm3:vel())*LArm3:mass())
RLeg3:applyForce(((O+A:up()*5+A:right()*10-RLeg3:pos())*10-RLeg3:vel())*RLeg3:mass())
LLeg3:applyForce(((O+A:up()*5+A:right()*-10-LLeg3:pos())*10-LLeg3:vel())*LLeg3:mass())
