Hey, I’ve stumbled onto a weird problem here.
I am trying to create a “local physics” environment in order to handle moving platforms/vehicles. The end goal is to be able to have two or more space ships moving in a scene while players navigate aboard the vessels as if they each have their own “no inertia + artificial gravity” field. I seem to have almost solved the problem mathematically, but on implementation the player drifts ever so slowly across the surface. I believe the problem is related to when physics is being updated relative to when the script is run, but I could be wrong. The logic is as follows:
#use relative position to calculate the tangential velocity at the player's location relPos = self.object.worldPosition - self.platform.worldPosition tanVel = self.platform.localAngularVelocity.cross(relPos) #apply tangential velocity, as well as any linear velocity self.object.worldLinearVelocity = tanvel + self.platform.worldLinearVelocity #account for rotation of the platform self.object.angularVelocity = self.platform.localAngularVelocity
I’ve tried everything I can think of to accomplish this and preserve the physics of the player object. Any ideas guys?