Hi there.
I’m tinkering with a basic 3D submarine game and want to make my sub level out smoothly at a given depth.
In manual control, the bow angle is controlled by the vertical axis. Its value is applied to a rotational acceleration which is added to a rotational speed around the X-axis (making it point up/down smoothly). The angle is subsequently clamped to +/- 80 degrees. The vessels position is then calculated by angle * speed thus increasing/decreasing depth.
However, I wish to set a depth and have the sub automatically ‘slerp’ to that depth using its usual rotational acceleration/speed values to calculate the slopes and curves.
I’m not sure how to calculate when the vessel should begin to level out in time to get to the correct depth.
Can anyone suggest the correct way to go about this or point me towards the correct formulas?