SpaceShip Gravity

: Hello, i’m working on a spaceship project, however i have some problems!

In this project the user will walk through the spaceship and will arrive in the panel and enter in a trigger. I disable the FPS controls and activate the spaceship control. So far its ok, i can accelerate and break with W, S and rotate the vision using the mouse.
The biggest problem is when i leave the chair. I set the spacebar key to do such action. If i leave the panel and it is rotational to any angle, like up or down, the FPS starts to slide due to gravity or rigidbody i guess.

There’s my question, because its a spaceship, there’s a artificial gravity independent of rotation. How do i do such gravity?!

Wow. That definitely sounds like a bit of a technical hurdle.

The first thing you’ll probably want to do is strip out the out-of-the-box FPS controller and roll your own with custom gravity and orientation. You might even look into parenting the controller to the ship itself so the frame of reference stays the same.

It might help to read this doc on how they did the gravity effects in Mario Galaxy as well:

Post a tutorial or something if you pull it off, because I’ve been pondering doing a ship to ground space sim for a while now.

I’m using this http://marraboy.blogspot.com/2008/10/spiral-galaxy-asset.html script for control my char.

I tried to use FauxGravityBody.js and FauxGravityAttractor.js but also without success!

Tnks for rpl and sorry for my English.

Didn’t read it all, but try this maybe.

// Disables gravity on all rigid bodies entering this collider.
function OnTriggerEnter (other : Collider)
{
    if (other.attachedRigidbody)
    {
        other.attachedRigidbody.useGravity = false;
    }
}
// Turn this collider into a trigger on startup
collider.isTrigger = true;

This is the correct script that i’m using for my char.

isn’t there a way to apply force to local axes? if so, id try making the character controller rotations relative to the spaceship’s :slight_smile: as a last resort, you could make the spaceship self-right when the player tries to leave the chair, or even make it so you cant walk about unless the ship is docked?

I am attaching an example of how the structure of the ship. An object nave with a collider to the ground and a cube with rigidbodyfps component.
The ship has a script attached ShipControl it, with the mouse to rotate and accelerate with the W and S.
Sorry for being annoying, this is for my thesis and I deliver on Tuesday = (

by google trans = (

329305–11610–$shipexample_682.unitypackage (5.8 KB)

If you set the value of Physics.gravity to the ship’s downward direction on each update, it should simulate artificial gravity:-

function FixedUpdate() {
   Physics.gravity = -ship.transform.up * gravityStrength;
}

Hope the thesis gets completed successfullly, by the way.

I’m having another problem now. I wish to make the Hyperspace effect and JumpEffect used on the StarWars and Star Trek movies, but i cant obtain the results by streching the particles. Does anyone have a suggestion?

Tnks

Actually my coder made this effect not too long ago…might help you…

static var warpBlast:boolean = false;
var lightStrength:float = 0;
var skip = 0;
lightStrength = gameObject.light.intensity;
function FixedUpdate () {
if (skip > 5)
{
if (space_movement.doWarp)
	{
		if (!warpBlast)
		{
			lightStrength = gameObject.light.intensity;
			lightStrength += 10 * Time.deltaTime;
			gameObject.light.intensity = lightStrength;
			Debug.Log ("lightStrength: " + lightStrength + " and deltatime: " + Time.deltaTime);
		}
		if (gameObject.light.intensity > 5)
		{
			warpBlast = true;
			lightStrength = 0.01;
			gameObject.light.intensity = lightStrength;
			Debug.Log ("light off: " + gameObject.light.intensity + " warpBlast: " + warpBlast);
		}
	}
	skip = 0;
}
skip += 1;
}