• attempts to convert an E2 to GLua, keep upright expected got uncontrollable spin
    0 replies, posted
i've been trying to keep an entity upright but all it wants to do is spin, the code of the E2 @inputs [E Chair]:entity @outputs Speed RA:entity @persist [E,User,WE,Chair]:entity Y Z W A S D F Shift Space EArr:array P interval(20) WE=entity():isWeldedTo() if(WE:isValidPhysics()){     E=WE } RA=rangerAngle(50,0,-90):entity() if(RA:isValidPhysics()&RA:type()=="prop_vehicle_prisoner_pod"){     Chair=RA } E:setMass(50000) User = Chair:driver() Earr = array(E,User,entity()) W = User:keyPressed("w") A = User:keyPressed("A") S = User:keyPressed("S") D = User:keyPressed("D") F = User:keyPressed("F") Shift = User:keySprint() Space = User:keyPressed("Space") E:applyForce(-E:vel()*E:mass()/2) rangerFilter(E) rangerHitWater(1) RanC = rangerOffset(100,E:pos()-vec(0,0,10)+E:boxCenter(),vec(0,0,-1)) E:applyForce(vec(0,0,2)*E:mass()*(100-RanC:distance())) E:applyForce((W-S+F*0.5-Space*0.5)*E:forward()*200*E:mass()) E:applyForce((Space-F+W*0.4-S*0.8)*E:up()*200*E:mass()) E:applyForce((A-D)*Shift*-E:right()*200*E:mass()) E:applyTorque( ( vec( (D-A)*30-E:angles():roll(), (W-S)*15-E:angles():pitch(), (A-D)*!Shift*20 )*5-E:angVelVector() )*E:mass()*0.75 ) this code is my latest attempt function ENT:PhysicsUpdate(PhysObj)     local seat=self:GetNWEntity("seat",NULL)     if !seat:IsValid() then return end     local driver=seat:GetDriver() --    if !driver:IsValid() then return end     local tr=util.TraceLine({         start=self:GetPos(),         endpos=self:GetPos()-Vector(0,0,100),         filter={self,driver,seat},     })     local leftover=1-tr.Fraction     PhysObj:ApplyForceCenter(Vector(0,0,leftover*2000-PhysObj:GetVelocity().z*50))     local E=PhysObj:GetAngles()     local W,A,S,D,F,Space=0,0,0,0,0,0,0--this will be replace later on     local R,P,Y=E.r,E.p,E.y     local V=PhysObj:GetAngleVelocity()*1     P=P+V.y     if R>180 then--left/right         R=R-360     end     if P>180 then         P=P-360     end     if Y>180 then         Y=Y-360     end     R=R-V.x     print(type(V))     PhysObj:ApplyTorqueCenter(Vector(R,P,0)) PrintMessage(HUD_PRINTTALK,P) end yet everything i tried just spazzes out my goal is to make my entity go into its upright position and damp out any swinging
Sorry, you need to Log In to post a reply to this thread.