@name Center of Mass Teleporter
@inputs Go Graber HoloEmit:wirelink Offset:vector NumState:vector Origin Enable
#@inputs EntityID
@outputs Grab Strength X1 Y1 Z1 Go XYZ:vector XYZholo:vector On
@persist Grab Offset:vector Jumpable
@trigger all
if(Enable){
interval(100)
Aim=entity():owner():aimEntity():id()
if(Aim){EntityID=Aim}


Tar = entity(EntityID):massCenter()
X1 = Tar:x()+Offset:x()
Y1 = Tar:y()+Offset:y()
Z1 = Tar:z()+20+Offset:z()
#Holoemitter
Xo = Tar:x()+Offset:x()
Yo = Tar:y()+Offset:y()
Zo = Tar:z()+Offset:z()

On=1
Teleport=entity():isConstrainedTo()
if(Grab){Teleport:setColor(255,0,0)}else{Teleport:setColor(255,255,255)}

if(NumState==vec(0,0,0)){Jumpable=1}else{Jumpable=0}
if(Jumpable){

if(Go){XYZ=vec(X1,Y1,Z1) Go=1}else{Go=0}

if (Graber & ~Graber) {Grab = !Grab print("Grabber="+Grab)}
if (Origin & ~Origin) {
    XYZ=Tar+vec(0,0,20)
    Go=1 
    print("Jumping to object origin")
    }
Strength = 10000
}

Size=5
XYZholo=vec(Xo,Yo,Zo)
HoloEmit["Pos",vector]=XYZholo
HoloEmit["Size",number]=Size
HoloEmit["Color",vector]=vec(0,128,255)
}
