Limiting the top speed of a rigidbody in 3d space?

Hi folks,
I’m trying to get my head around certain mechanics of space flight. Basically what I want to implement is a top speed relative to the local environment for my ships.

My thrust is given through rigidbody.addRelativeForce however I want to limit the top speed for objects for various reasons.

My initial approach was to just limit the maximum velocity along each axis of the velocity vector. I would check the axes of the velocity vector and reduce the component of the force vector to zero if the maxspeed had been reached for that axis.

However if for example the vehicle hits 100m/s on the x axis turns and then travels at 100m/s along the y axis the resultant velocity is 141m/s.

I’ve considered applying a global drag factor so as the vehicle turns it bleeds speed off naturally however this hampers the mechanic where a vehicle could float past another vehicle without the engines running (i.e. stealth attack :wink:

I’ve been suggested in other forums to just work with the rigidbody.velocity function and just run with a normalised vector and multiply it against a magnitude. Unity documentation recommends against this and I can see a few problems with this approach.

My next approach will be to apply a drag factor specific to the vehicle only when the engines are running to reduce the velocity in directions the vehicle isn’t flying directly in.

Has anyone got a better idea or am I just overcomplicating the issue? Thanks

I have a similar thing I was trying to do, and my solution was to check the current velocity as a maximum.

currentVelocity = GetComponent.<Rigidbody>().velocity.magnitude;

Then I would check to see if that velocity exceeded a predetermined limit and take an appropriate action.

if (currentVelocity >= maxVelocity) {
		GetComponent.<Rigidbody>().drag = 10;
	}
else {
GetComponent.<Rigidbody>().drag = 0;
}

Not sure if that helps