Space Flight

Hi

I am working on a space flight simulation and I have some questions to ask:

First for roll movements(for rotation around Z) I added another axis and set keybord buttons as controllers. My problem is that my ship wont stop rolling after I stop pushing the button. I tried to stop rolling manually but didnt work.

Second I want to add a mesh explosion animation as in 3Ds Max but I dont think it can be done. Should I model my ships in parts for explosion or is there a method that I miss.

My simplified movement controls for your comment:

var thrust = 10.0;
var rotateSpeed = 1.0;
var controller : CharacterController = GetComponent( CharacterController );

function Update(){
		RotateAroundSelf();
}



function FixedUpdate(){
	rigidbody.AddForce( transform.forward * thrust );
}
	


function RotateAroundSelf(){
	transform.Rotate( Input.GetAxis( "Vertical" ) * rotateSpeed, Input.GetAxis( "Horizontal" ) * rotateSpeed, Input.GetAxis( "Pitch" ) * rotateSpeed );
	
}

Thanks for the help in advance
Bahadir Boge

Do you mean that if you press one of the ‘roll’ keys and then release it (so that no keys are being pressed), the ship continues to rotate?

If so, you might compare the setup for the ‘roll’ axis to the setups for the other two axes to make sure the roll axis is set up correctly. (I’m not sure if that’s what’s causing the problem, but it seems that if the smoothing values weren’t set correctly, you could end up with the effect of continued motion when the key was released.)

Thanks for the fast reply.

I checked that and there is a difference. Vertical and Horizantal axises has type of Joystick and their Axis types are X and Y. My pitch axis has type of Key or Mouse Button(doesnt work at all when i changed this to joystick or scroll axis) and axis is 3th-8th axis(tried all: same result).

It could be that the change of rotation is reacting badly with the physics engine. Generally, you should turn a rigidbody object by adding torque. There is an AddTorque function, but for a spaceship, you may it better to simulate thrust from orientation thrusters. You can do this by using AddForceAtPosition to push the rigidbody at a position away from its centre of mass (which will make it spin as well as move).

AddTorque/AddForceAtPosition I will add these but my take some time to adjust. Course correction may need adjustment.

you might want to also try increasing the angular drag. This causes rotating objects to slow down. By default it’s very low, so for something not colliding with anything, will continue spinning for a while