floating E2 block above my head help

I’m trying to make a E2 that floats above my head and aims where I point like I’ve seen all over gmod. So far my efforts have been unsuccessful. Here’s what I got so far.


@name 
@inputs 
@outputs 
@persist 
@trigger 
@model models/hunter/blocks/cube025x025x025.mdl
interval(1)
entity():applyForce(owner():pos()-entity():pos()+vec(0,0,100))
entity():setMass(0.08)


This works as long as I don’t run. When I run or noclip the E2 decides to sit where it was, frozen in the air. Any help would be grate.


@name MatadorForAll
@persist E:entity O:entity Hold Attack Dest:vector Vec:vector Ang:angle
if(first()){
    #Make the angle for the death ball to spin randomly
    A = 45
    Ang = ang(randint(-A,A),randint(-A,A),randint(-A,A)) * 50000
    #Hide the chip
    entity():setColor(0,0,0,0)
    O = owner()
    runOnTick(1)
}

Pos=E:pos()
#Spin the ball randomly
E:applyAngForce(Ang+$Ang*5)
#Only hover if the owner is alive
if(O:isAlive()){
    #If holding, then move the chip above the owners head
    if(Hold){
        #Set Destination
        Dest=O:pos()+vec(0,0,(200+E:radius()))
        #If the ball is close, move slowly and accurately
        if(Pos:distance(Dest)<50){
            Attack = 0
            Vec=(Dest-Pos)*E:mass()
            E:applyForce(Vec+$Vec*5)
        }
        #If its far away, move quickly
        else{
            Vec=(Dest-Pos)*E:mass()*Pos:distance(Dest)*50000
            E:applyForce(Vec)
        }
    }
    #If the owner left clicks, start the attack sequence
    if(Attack==0&O:keyAttack1()&E&O:aimEntity()!=E){
        #Just incase it gets stuck
        stoptimer("ManualReset")
        timer("ManualReset",3000)
        Dest=O:aimPos()
        Hold=0
        Attack=1
    }
    #Attack Code - Strikes the spot once
    if(Attack==1){
        Vec=(Dest-Pos)*E:mass()*50000*Pos:distance(Dest)
        E:applyForce(Vec)
        #When the ball reaches its target, go back to holding
        if((Pos:distance(Dest)<20)){
            Attack=2
            Hold=1
        }
    }
    #Attack 2 code - Flys constantly at the spot
    if(O:keyAttack2()&E&O:aimEntity()!=E){
        Attack=0
        Hold=1
        Dest=O:aimPos()
        Vec=(Dest-Pos)*E:mass()*50000*Pos:distance(Dest)
        E:applyForce(Vec)
    }
    if((O:keyUse()|O:keyAttack1()|O:keyAttack2())&!E){
        print("ERROR: No prop selected")
    }
    #If porp is stuck, return to owner
    if(clk("ManualReset")){
        Attack=0
        Hold=1
    }
    #Prop selection code
    if(O:keyUse()&O:aimEntity()&O:aimEntity()!=E){
        #Set the old prop to 5 mass and remove the trail
        E:setMass(5)
        E:removeTrails()
        #Designate the new prop and play with its properties
        E=O:aimEntity()
        E:setMaterial("models/debug/debugwhite")
        #E:setMaterial("models/props_combine/metal_combinebridge001")
        E:setMass(80000)
        print("Prop selected")
        Hold=1
    }
}


I know it’s probably not what you want but it’s a E2 that makes a proper hover above your head and follows you around (also I didn’t make it got it from a E2 thread)

yea not really what i was looking for. i just want the e2 to float above my head and aim where i aim with the model of the .25x.25x.25 phx block. im just having trouble with it staying above me.

entity():applyForce(owner():pos()-entity():pos()+vec(0,0,100)*entity():isWeldedTo():mass())

oh and add

runOnTick(1)

Use this formula:


(((TargetPos-CurrentPos)*Multiplier-Velocity)*Mass)

I usually use 20, 50, or 100 for the Multiplier. Lower multiplier = slower speed. Higher multiplier = faster. Too high and it freaks out.
This means the code would be something like


@persist E:entity
if (first()) {
    E = entity()
    runOnTick(1)
}
E:applyForce(((owner():pos()+vec(0,0,200)-E:pos())*20-E:vel())*E:mass())

thanks Divran. Again. Are you stalking me?

now to make it aim

still cant figure it out. heres what i got


@name box
@outputs V:vector A:angle S:angle
@persist E:entity D:angle
@model models/hunter/blocks/cube025x025x025.mdl
if (first()) {
    E = entity()
    runOnTick(1)
}
E:applyForce(((owner():pos()+vec(0,0,100)
    -E:pos())*40-E:vel())*E:mass())

V=owner():aimPos()
A=owner():eyeAngles()
S=E:angles()


#E:applyAngForce(A-S)
#E:setAng(A)