[Solved] Nullifying a physic objects movement yet applying the force

Sorry for the convoluted title there.

What I have is a player’s spaceship that I want to apply thrust to for movement. I followed the tutorials and boom. It works like a charm.

So far so good.

The issue is that I’m trying to keep the ship at the origin while doing this and using the resulting movement of the item to move space around it.

To show you what lunacy I was attempting check this out.


So ya. That doesn’t work.

Another thought occurs that perhaps what I should do is simply apply the force on an invisible object and copy it’s values onto the player’s model. Just reset the dummy physics objects position back to it’s origin on a regular basis artificially.

Would this make sense or am I giving myself more heartburn down that route?

Why is it that you are trying to do it this way?

…versus keeping the game objects separate from the view objects so that the game objects can move wherever they want and you just adjust the scene-relative view objects to be centered around the player.

1 Like

Like Paul said. But rather than write what he means, he already wrote it. Move the world, not the player. Paul’s github is a bit of a gold mine for jmonkey. I read through it often.

1 Like

I had thought (probably erroneously) that when you’re moving an item it’s position would eventually run into float point accuracy issues for REALLY big values.

But what I’m reading in your reply is to just let the physics object move however it wants to, keeping the camera on the player, and use the position of the physics object to handle any sort of zone loading I’m doing. On top of that just don’t worry about the float point inaccuracy when moving the player with physics.

Am I interpreting what you mean correctly or has my cheese slid of its’ cracker?

Thanks! I have been looking through his stuff on this. Just haven’t really sat down to pour over absolutely everything.

Ok. Maybe I’m more confused than I had thought…

I have made some code that allows the world to move around the ship. Before I was just doing this by taking the velocity of the ship (this was done by just making up a movement vector) inverting it and applying it to the world instead of the ship. This worked fine but naturally doesn’t use proper physics.

Do I just do essentially the same thing but apply the thrust to the world instead of the ship? This sounds reasonable… just also sounds a little nutty.

No. You keep the game objects separate from the view objects. So you don’t use Spatial with a RigidBodyControl. You use a RigidBody to move your ship.

…then you place the view elements (the Spatials) around 0,0,0 based on where they are relative to the player.

And yes, with floating point you will start to run into accuracy issues at higher values… but that’s a float-based bullet limitation and there is no good way around it. Definitely not on the path you were trying to take.

If you only want to handle physics for some immediate area around the player then you will have to divide space into zones and rearrange the zones once the player crosses a boundary. So instead of moving all of space around the player all the time… you only do it at zone boundaries. Else your physics is going to be impossible.

Ahhhhhhhhhhhhhhh ok. I think I see what you mean.

Right now I’ve attached the rigidbody to the spatial a la the tutorial. Instead have them apart and simply update the ship “location” based on where the rigidbody is.

Yup. I already have a system doing that.

I’ll give this all a whirl tonight and hopefully reply back with success.