Unfortunately gravity, acceleration, force, etc does *NOT* work how it should in gmod. Even if you use a figure like 600 somewhere in your calculations, it won't work... I've tried MANY times. There is, however, an upward force needed to counteract gravity for a given mass. I tried to get a formula for this, but it jumps around and is pretty damn erratic. If you have, like you say a camera, you only have to calculate this force once. Something like this:
e2 Code:
@inputs Ent:entity
@persist Calibration
runOnTick(1)
Calibration += entity():vel():z()
EE:applyForce(Calibration*vec(0,0,1))
It will struggle a bit but it will eventually get there. You might want to mess with a multiplier or something on Calibration. Obviously, do this with gravity on. Once it settles and stops moving up and down, save the number using a debugger or something.
You could probably just make one E2 that does this and change the E2 to the weight of the prop you'll end up using + 1 for the weight of the expression that I assume you'll be attaching to said prop.
But when I came into this topic I was thinking about another way to do it.
e2 Code:
@inputs ENT
runOnTick(1)
Held = entity():owner:isBeingHeld() #I'm not really sure of the function, whatever tells you if its being frozen or not
Pos = ENT:pos()
SomeMultiplier = ???
if((~Held & !Held) | first()) #if someone just stopped holding it
{HoldPos = Pos} #make that position it stopped being held at the position to stick to
ENT:applyForce(SomeMultiplier*(HoldPos - Pos - ENT:vel())
Hope this helps.
EDIT: Forgot about adding in the air friction part of it.
Bookmarks