Having finished my first app and now that it is shipping, I want to ask a general question of the community about the Ageia Physx engine.
I developed a pinball machine to scale, which make it about 6 feet or 2 meters high. The pinball itself is 1.06 inches or 27 cm in diameter. I ran into all kinds of grief when I tried to use 1:1 scaling with Unity and spent hours trying to keep the pinball from sinking through the table and other objects. You might say that I did not have the collision detection set properly or perhaps the friction, but I did literally tweak those parameter countless times.
I eventually had to scale the model up to get the physics engine to behave properly and not have objects sink through each other and detect collisions properly. The first case was more worrisome since the ball was usually stationary and would sink through the table with zero velocity.
I even ended up doing some collision detection myself in scripts because the physics engine refused to detect when the pinball went through a fence or a wall that was fairly thin. I think this is more easily attributed to the ball traveling from the front through the back of a wall in less than one frame time, but I was finally successful in stopping the unwanted behavior.
Scaling the model up also meant that the default gravitational constant was no longer correct and I had to tweak that as well. So the pinball machine has gravity that is closer to that of Jupiter than Earth.
Enough of my sad tale. My question is – at what dimensions does the Ageia engine no longer work properly? I want avoid these problems in the future if at all possible, or perhaps find an alternative solution that I missed.
–Steve
Did you tweak “min penetration for penalty”? I haven’t tried, but I expect you could get physics working properly at the correct scale. It also sounds like your collision issues will happen anyway, regardless of scale, if you’re using concave mesh colliders (pinballs move quite fast relative to the thickness of the objects they’re hitting). If concave colliders are unavoidable, perhaps you could begin the project with an insanely high physics timestep–like 200hz–and make sure it stays performant throughout development.
Although your use of “app” implies iPhone, in which case using PhysX is going to be problematic no matter what you do; a solid pinball experience on the iPhone will probably require a purpose-built physics engine.
Still, I wouldn’t obsess over scale in a project like this. PhysX units are likely stable by default at around people-sized things. My recommendation for a pinball project would be to define the ball as 1 unit and adjust everything else to match.
Thanks for the reply Matthew. I was not really worried that much about the scale, but it did cause hours (maybe days) of work tweaking the scale and the gravitational constant to get the pinball physics to look realistic.
I should mention that the pinball is 27mm not 27cm, my mistake.
The app (yes, on an iPhone) has the double whammy of not refreshing at anything near even 60 Hz for decent collision detection with smaller or thinner objects. I should also say that the physics engine still had problems with the min penetration for penalty at 0.001, and yes, I tweaked that many times as well.
I did start with the game on the desktop version of Unity and had the same problems. It seems to be a limitation of the physics engine itself. While many things moved straight over to the iPhone version, the physics was another exercise in iteration to get the scale and gravity correct for the iPhone.
By the way, your suggestion of calling the pinball dimension 1 unit is very close to what I ended up with. To keep my own sanity as I developed and added new objects or changed object, I chose decimeters as the unit scale value making the pinball 0.27 units (dm) in diameter. Choosing centimeters as the unit value made the gravitational constant so high that the pinball looked liked 100 lb lead weight rolling down the table, which does not look realistic. In fact, due to the non-linearity of gravity, there was a trade-off between the gravitational constant and how sensitive the collision detection was.
Thanks again for the reply.