- Home /
Marble rapidly loses momentum after rolling down ramp, then rolls indefinitely
Hey all,
I am working on a project with marbles. I have a ramp, and the marble rolls down it reasonably, but once it rolls onto a flat surface, it loses most of its momentum, then maintains that momentum indefinitely.
Here's a zip of the html: https://www.dropbox.com/s/5sug0hxotdf769y/Marble.zip?dl=0
Here are my settings: https://www.dropbox.com/s/u2gikt4wahoyfqv/MarbleSettings.png?dl=0
I scaled the physics and time because the marble is supposed to be 1cm, but I have scale it to 1m (1 unit in Unity). Dealing with spheres at 0.1 scale was.. difficult.
Does anyone have any idea what is happening, why, and what I can do about it?
Thanks!
I think most folks would appreciate a video ins$$anonymous$$d of a project or whatever it is you're offering ins$$anonymous$$d. I'd expect very few takers when we cannot observe the problem in 10 seconds.
Talking about fiddling with the time and physics settings is a red flag; I'm not saying you shouldn't do that, but that leaps out as a potential source for odd behavior.
Note that the physics material of both objects is important, particularly the bounce and friction combine settings, which can override expected behavior if not properly tailored to the situation.
Choosing an appropriate scale for your game is an important decision. Without experience with PhysX, many newcomers assume that they should mimic real-world scales in every situation; from marbles on a tabletop to suns and planets in space. However, it's usually the case that there's a "sweet spot" for scale that will produce the most stable, satisfying behavior.
Consider a 2m (2 unity units) human. The smallest dynamic objects he'll interact with might be baseball sized, and the largest might be vehicle sized. This range is about what you should expect to behave well together. I always target a similar range and basis for scale whenever possible.
I've gotten these physics and time properties from another thread somewhere related to the same issue. Our project has specifically to do with marbles, and so we need that scale of objects, and physics that work for that scale. We don't have the luxury of using baseballs or volleyballs for our purpose.
You are misunderstanding my comment:
PhysX doesn't care what objects you are representing. The scale of your world should reflect the "sweet spot" PhysX targets. You will need to balance your masses, drags, coefficients of friction, etc, to correspond to the shifted scale.
PhysX is incredibly unwieldy at too-large and too-small scales; it is standard operating procedure to enforce a scale in your game world (in Unity units) that corresponds to the scales at which PhysX is most stable.
There is a great deal of wiggle-room in making this decision, which is why it's difficult to speak definitively, but having your average body be 1 unity unit in diameter sounds just fine. Your relative scales, masses, and coefficients elsewhere throughout the project should reflect this shifted scale, but to a great degree, dialing in physics coefficients is a matter of trial and error.
Besides the interaction between phys materials and their respective blending modes, only a frictionless resultant interaction with zero drag should ever produce a maintained velocity in PhysX. If you're witnessing something else, and you're certain your coefficients and blending modes are reasonable, there's something else going on, and to me, the red flag is altering the time and physics properties of the project.
It could conceivably have something to do with the quality of the colliders in the game environment, or some coding oversight in whatever method(s) apply forces to the object(s).
We need to adjust physics and time because we're dealing with marbles. Deciding on 1 unity unit being 1cm ins$$anonymous$$d of 1m means we need heavier gravity. A volleyball falling 2m takes longer to fall than a marble falling 2cm. Without adjusting the physics and time then our marble falls much slower than it should because it's trying to move x units per second where x is in meters ins$$anonymous$$d of centimeters. In short, red flag or not, dealing with marbles means I have to adjust physics and time and it's not a red flag. Google around, it's the accepted solution.
We are not disagreeing, I promise. I am attempting to indicate that this approach introduces its own caveats which must be considered; I now understand that you were previously aware of the most critical of these.
When no glaring mistakes or misunderstandings are obvious, all anyone can do is help with brainstor$$anonymous$$g. Getting gross physical interactions up and running is as easy as adding the right components, but what I'm hoping to convey is: Dialing in the perfect combination of coefficients to achieve a particular "feel" in PhysX, particularly when it's the game's mechanical focus and you're working with a non-real-world scale as you must in your scenario, is not a cut and dry task. $$anonymous$$ore often than not, anyway, you'll be spending a good bit of time and effort tuning these dozen or so interrelated variables to achieve a desirable result. Oddities may emerge and edge cases may need to be addressed with scripted kinematics.
Granted, your case sounds pretty weird, and you seem to have a good handle on what you're doing and why. $$anonymous$$y suggestion then becomes searching for discussions of similar problems, perhaps additional research into working with unusual scales in PhysX. Also general research into PhysX and its numerous quirks and Best Practice guidelines regarding colliders and physical scenarios.
Construct test scenarios for yourself to test and observe behaviors with different physics properties and objects. I've been down similar roads many times over; each time, a different set of factors emerged as problem areas depending on the desired result. The answer in many cases involved deviating from expected values; in other words, "fudging it" until it behaved as desired.
Bottom line, this particular issue may or may not be a manifestation of such a quirk or the result of deviating from established practices. Volunteer motivation to dig into such issues on your behalf will be low, mostly because it's always such a pain, regardless of your level of familiarity. ;)