Keeping a CharacterController Perpindicular to the Ground

I have a hover craft script that uses CharacterController to move along the ground, it uses transform.Rotate() to turn. This works fine on flat ground, but when i go up a slope or incline the craft is still upright, i want it to be perpendicular to the ground. I have tried using Quaternion.AngleAxis() and Vector3.Angle along with raycast below the craft. This did not work it didn’t put the craft in the right orientation and didn’t allow me to steer. Is there a way to get it perpendicular to the ground and still maintain relative steering?

You’ll have to do a ray cast and then adjust the rotation based off the results. There is a free video series on 3DBuzz.com about third person controllers that would probably help dramatically. I remember seeing them handle slopes so that might help.

You can’t use a CharacterController for that, since it’s always upright. A CharacterController is not appropriate for vehicles anyway.

Here is my solution:

		float curGroundAlignDist = Motor.SlowGroundAlignDist + ((Motor.FastGroundAlignDist - Motor.SlowGroundAlignDist)* Motor.curSpeed/Motor.HighSpeed);
		RaycastHit ground;
		RaycastHit fwd = new RaycastHit();
		Vector3 down = thisTransform.TransformDirection(Vector3.up * -1);
		Physics.Raycast(thisTransform.position, down, out ground, Motor.GroundConformDist);
		float calcFwdAngle = -1 * Mathf.Rad2Deg * Mathf.Atan(Vector3.Distance(thisTransform.position, fwd.point)/Vector3.Distance(thisTransform.position, ground.point));
		if(Physics.Raycast(thisTransform.position, thisTransform.TransformDirection(Vector3.forward), out fwd, curGroundAlignDist))
		{
			if(fwd.point != Vector3.zero)
				Angle = Mathf.Lerp(Angle, calcFwdAngle, Time.deltaTime/2);
		}
		if(fwd.point == Vector3.zero)
			Angle = Mathf.Lerp(Angle, 0, Time.deltaTime/2);
		if(ground.point == Vector3.zero && fwd.point == Vector3.zero)
			Angle = Mathf.Lerp(Angle, 35, Time.deltaTime/2);
		if(Angle < Motor.MaxIncline * -1)
			Angle = Motor.MaxIncline * -1;

Then I use that Angle in to modify the Euler of my Character controller, i also moved my steering to the euler.