I am not very good at maths and I managed to salvage some math from other hover vehicles to create this, however there is a very huge problem. What I hope to achieve here is to create a smooth hover vehicle which doesn’t bounce out of control once I change network ownership or enter a lower or high point of terrain.
Forward and steering movement is quite smooth currently however the only issue being that the Y axis which is supposed to keep it stable and hover goes insane when network ownership is switched to a player, or you go to a lower point of terrain.
This might sound confusing but i’ll put it simply: ’ The hover vehicle does not keep still on the Y axis and fails to keep stable when going to a lower point of terrain ’
The control law you are using to stabilize the body doesn’t really make sense. I see you have a feedfoward term with GetMass, but then you have a bunch of of random stuff that is dependent on the distance from the floor.
If you are just beginning to learn how to program, I would recommend you start out with just a PID controller (without I or D terms…). This means that you get a control law u = FF + error *p where error is your setpoint distance - observed distance. FeedFoward (FF) is just the weight of your object.
As you improve your programming & mathematics skills, you can then apply more advanced control system techniques to have better performance. LQR control and even MPC could be applied if you wish.
The distance to the floor provides the amount of force required to reach a certain level above from the ground which is static and cannot be dynamicaly changed the rays provide the distance the hover vehicle is from the floor.
Using a different body mover helped an extreme amount, I can now mark this as my solution.
I basically was using a vectorforce to move up and down but it was being too reactive because of the amount of times force was changing.