18

Always assume the client is a lying, cheating, bastard. The client is responsible for: Receiving input from the player (and sending commands to the server, which validates) Rendering the known gamestate The client is in no way allowed to calculate the gamestate except as client-side interpolation for smooth animations.


11

Bullet does not allow the transform associated with a RigidBody to have any scale or shear in it. This is not uncommon; many other physics engines have this restriction as scale and shear can make the internal dynamics simulation very difficult to solve. Instead of scaling the rigid body you will need to instead scale the shape used for collision detection. ...


11

To maintain the shape while spreading, each bullet needs to have a different speed. Suppose you are going to create a "wave" of bullets originating from a centerpoint, what you need to do is to calculate the speed each bullet needs to have to maintain the contour of the shape. See below: the red bullet moves slower than the green bullet in order to enlarge ...


10

It turns out the solution is much simpler than the original attempt, and there's no need for subclassing if you're just testing one ray collision. Here's all you must do to retrieve the collision vector: btVector3 btFrom(camPos.x, camPos.y, camPos.z); btVector3 btTo(camPos.x, -5000.0f, camPos.z); btCollisionWorld::ClosestRayResultCallback res(btFrom, btTo)...


10

There are three reasons collision margins may exist in physics simulations. As you suggested, a collision margin gives the physics engine some room for error in detecting contacts and resolving contacts, prior to actual penetration. This helps with the appearance of realism as objects do not visibly poke through the ground, etc. There are nuances here for ...


8

I just write the body and shape values to a file. Then when reading them, I create a new body and shape and set the values to those read from the file. From what I've seen this works great. I haven't seen any strange behaviors or anything like that. Bodies that were flying through the air, continue to do so when the game is reloaded. The values I read/write ...


7

Real-life gunsights have the exact same problem. There are several ways you can deal with it: Do nothing. Just have the bullets fly from the gun in the direction the player is facing, and accept that they won't hit exactly where the player is looking at, but rather some distance below and maybe off to one side. This is a reasonable choice for characters ...


6

The shell's speed was the same as the ship's speed before it got fired, if you think about it. It was sitting on the ship. So, if you add the velocity from being fired to the velocity of the ship, you should get the correct result.


6

I don't know if it is because of a poor component that causes the false readings or a extremely precise component that registers the spinning of the earth, as it orbits the sun, as our solar system spirals through the galaxy. Either way, this is a common problem. The solution is to use some type of filter to smooth out the "extra" readings. There are ...


5

From your latest comments, it looks like you're trying to save/restore all the internal simulation state inside Bullet (overlapping pairs, contact points, etc.). This sounds... daunting! Another idea: Every frame, remove and re-add all your dynamic objects. Obviously, this is hugely bad for performance, but you indicated that you don't have many dynamic ...


5

You could use world->contactTest(player, callback); This will use the same dynamic aaabb tree (if you use btDbvtBroadphase) and uses an exact contact computation. It is probably fastest and easiest. World can be btCollisionWorld or btDiscreteDynamicsWorld. If you use ghosts: You don't need to add a ghost for each item, just a single ghost around the player....


5

Something seems wrong to me in your implementation of the authoritative server. Basically an authoritative server controls everything. It is the pivot of your network architecture. Clients just "ask gently" when they want to do some actions, and the server has the authority to say "NO I DON'T WANT YOU TO DO THAT BECAUSE I'M THE BOSS HERE!"...


4

You need proper client-side prediction. You should really read in details the link Roy T. provided you in his comment. It describes what to do with player input & character physics, but the principle stays the same for "server-driven physics". This isn't trivial to implement but in a few words, for game objects that need to be in sync: Run the physics ...


4

This sounds like numerical instability due to floating point inaccuracy. Are you using the scale factors for your scene/objects as per the vendor's recommendation? Edit: General checklist for physics engine jitter Make sure you are using the correct scale factors Make sure that the quantities are reasonable (e.g. 10m, 80kg, ...) Enable sleeping if this is ...


4

Replace your new line with: entity.getBody().setLinearVelocity(platformVelocity); You might want to do the same for the shell also instead of finding desired impulse, which depends on the mass of the shell.


4

There's no need to shove a pre-made physics engine into a particular model. All good physics engines are going to be using some form of data oriented design; you can't have a fast physics engine without cache optimization. This means that any benefits from attempting an Entity Component System, or any other data oriented approach will be redundant. What you ...


4

One way you can do this is to setup a sphere ghost collider and detect when something collides with it. Then you can change the gravity vector to point towards the centroid of your planet for anything that collides with it that you want gravity to affect. A much harder way to do this would be to concoct your own constraint. The constraint would be very ...


4

This is a classical control problem. You want to create a feedback loop that takes the divergence from optimal position and applies the appropriate torque to nudge it back into position. btQuaternion targetOrientation = // whatever you need btQuaternion currentOrientation = myObject->getOrientation(); Getting the delta orientation is quite simple, you ...


4

You can do it using btConvexHullShape, calling the addPoint method. But that's usually not what you want. You should manually make a much much simpler collision mesh in your 3D modeling tool. Collision meshes don't have to be detailed. Use only a few triangles. A good way to create an accurate representation is to use a compound shape (btCompoundShape) ...


3

So, if I understood your problem, you have a way to set an initial state, and a consistent function for advancing the state by one frame. You also have a way to retrieve a current state, but it is not reliable, since restoring to it gives different results than if you had not restored it in the first place. In that case, I have three options for you to ...


3

Looking on the Bullet Physics forums I found a comment from Erwin (the author): FrameA and FrameB are constraint frames in local spaces A and B respectively Limits give the allowable range of movement if frameB in frameA space (or vice versa if useLinearReferenceFrameA == false) He then supplies some sample code to try: { // create a generic 6DOF ...


3

You need to make the physics object a kinematic object. See Bullet Physics Manual for more information. Bullet Physics ask every frame the current transformation from kinematic objects. You need your own MotionState implementation for that. Mine is as simple as this: public class KinematicMotionState extends MotionState { private Transform ...


3

I was having some troubles with the strategy implemented in my other answer. Contact points would sometimes stick around, it was kind of hacky to do shapes other than cubes and it would sometimes allow objects to slip through the terrain. So instead of modifying or overriding any of the Bullet classes, there is an alternative option of using a built in ...


3

What I do personally is whoever is hosting the game creates the phsyics world and sync objects with the clients. Even if its a p2p network scheme I still base the physics engine on one of the players clients. Other physics that I use that is purely eye candy doesn't even need to be synchronized. In a prototype I made a while back called "boilerzerker", I ...


3

Boxes are not what you want; they are solid. (That is, they have a filled interior. Anything inside a box will be thrown out of it.) Assuming you wrap the triangle mesh in some sort of bounding hierarchy (such as Havok's MOPP or Bullet's BvhTriangleMesh) you should not see any performance problems unless you are running massive numbers of casts or ...


3

I'm guessing this is due to the collision resolution. Gravity pulls your character down and you start penetrating the slope. The collision is resolved along the slope normal, so you move out diagonally. Each frame the character moves down from gravity, and out slanted. You can imagine that since the resolution is slanted and gravity is downward, over time ...


3

Well I don't think that Bullet physics support multiple attractors out of the box, even though in bullet you can set the gravity per object, Bullet still assumes the objects are being simulated under a global gravity value set for the entire scene, in other words it assumes that the objects gravitational force is neglected in comparison to the planet/surface ...


3

I looked in this issue, and it seems that you have to call the activate function on the rigidbody after applying the force. This article does say that you generally do not have to but it seems that you must do it manually once it is has gone to sleep.


3

The parameters low and high are the angles restricting the hinge. The angle between the two bodies stays in that range. For no restriction, you pass a lower limit <= -pi and an upper limit >= pi here. This might be useful for things that rotate completely around other things, for example wheels on a car. For the other three parameters, I can only guess, ...


3

As a mechanical engineer whose also interested in game development I appreciate how difficult this problem can become; anything more than the naive solution I am about to describe requires a sound understanding of control systems. Simple Solution I am developing a 2d game where players have control over a spaceship (approach should work just as well for AI ...


Only top voted, non community-wiki answers of a minimum length are eligible