Hi, I’m trying to make a entity which hovers at a specific height (Z coordinate).
Can you help me find a good approach to this? My first idea was to copy gmod_hoverball code which use ENT:PhysicsSimulate, but when I start applying force in different ways it becomes unstable. I also found it hard to control the objects movement and “lock” the objects pitch and roll axis. Using SetAngles to lock pitch-roll/x-z axis doesn’t work here because it also stops movement for some reason.
Next try was to use hoverball-code to fix its Z-value but phys:ApplyForceCenter and phys:ApplyForceOffset to control movement. This didn’t work out since ENT:PhysSimulate would either spas out, stop being called and the code related to rotating left/right would sometimes move the opposite direction based on if x was positive or negative.
Last try used SetMoveType( MOVETYPE_FLY ) and SetVelocity/SetLocalAngularVelocity for movement, but it seems like all physics are disabled and collisions between objects with MOVETYPE_FLY doesn’t call ENT:PhysicsCollide.
I liked my last solution because it’s simple and I don’t have to worry about setting X/Z angles or Z coordinate, but it feels hacky and doesn’t work if collisions are disabled.