# Moving a PhysicsSpace

Hi! My goal is to create a planet that revolves around a star, and allow players to wander around on the planet, drive cars, etc, while it moves. I already have this working successfully by attaching the planet to a node in the center of the star, then rotating the planet node and star node independently to create both the motion of the planet rotating on its axis as well as the planet revolving around the star, and I use quaternions to rotate the player, and they do stay on the planet while it rotates and such. The problem is that it is very unstable with physics involved. Players can easily walk through objects, when they are falling it is jittery, etc. A while ago I created a topic about keeping the player on the planet and â€śzarchâ€ť said â€śâ€¦I think the solution would be to set up a physics space for the planet and have it effectively stationary.â€ť Hereâ€™s the post. I am still using BetterCharacterControl.

Basically what I want to do is just what zarch said, create a PhysicsSpace and attach it to the planet while it rotates, that way I wonâ€™t need to update the playersâ€™ positions and such, only the PhysicsSpace. The problem is moving the PhysicsSpace. I donâ€™t know how to do this, or if it is even possible. Does anyone know?

Thanks

Sorry, I didnâ€™t quote everything I wanted to from zarch. Hereâ€™s a better quote:

"I think the solution would be to set up a physics space for the planet and have it effectively stationary.

i.e. run all the physics state stationary and then move the entire node and entire physics space to produce the movements of the planet.

Once you leave the planet switch off physics again (or change to â€śspace physicsâ€ť mode) until you get close enough to another one."

Off Topic Edit: Why canâ€™t I edit my main post, but I can edit my replies? Thatâ€™s odd.

Its actually pretty easy, you just make multiple physics app states and set the physics control to setApplyPhysicsLocal, then you attach the respective spatials all to one node and treat it as the local physics system, i.e. the planet.

1 Like

Thank you normen! Iâ€™ll try this out and let you know how it works.

Iâ€™m probably misunderstanding what Iâ€™m supposed to do. Hereâ€™s what Iâ€™m doing:

First I create a node for the player and attach the control to it:

[java]
playerNode = new Node();

Then I assign a planet to the player:

[java]
public void setBulletAppState(BulletAppState state)
{
if(this.bulletAppState != null)
{
this.bulletAppState.getPhysicsSpace().remove(this);
}
this.bulletAppState = state;
}

â€¦

this.setBulletAppState(planet.getBulletAppState());
planet.getPlanetNode().attachChild(this.getNode());
this.setApplyPhysicsLocal(true);[/java]

This should add the playerâ€™s node to the planetâ€™s node, as well as add the player to the bulletAppState assigned to the planet. When the planet rotates, though, the player doesnâ€™t move with it. I know I left out a lot of code, if I need to post more let me know, feel free to ask me all kinds of questions, I really donâ€™t know where to go with this

Thanks for the help.

You should do something like: