- Home /
Strange sphere/physics rolling behaviour when scaled
Hi I have a sphere (imported model) rolling along a flat surface. It's controlled by the arrow keys via AddForce(). It works very well, and the physics engine and friction take care of it rolling (rather than sliding) realistically. I can import the ball at any size and it works consistently, however if I manually scale the ball's transform instead, by half (.5,.5,.5), or less, it moves very jerkily. I've tried adjusting the friction settings, in case the engine uses scale for it's friction calculation, but to no avail.
At various points in the game I need this ball to be continuously scaleable. Is there another way to approach this problem?
Thanks
Answer by Tommynator · Sep 22, 2011 at 09:48 AM
What kind of Collider are you using for your imported sphere model? If it's a MeshCollider, make sure to check 'convex' and 'smooth sphere collisions' in the component properties. I also don't recommend you to use MeshColliders if the base mesh very high poly, as you will run into performance issues quickly.
As an alternative I suggest to attach the built-in sphere collider. That should be insensitive to scale.
hope that helps - looking forward to the next Katamari Damacy ;)
Thanks, but I'm already using a sphere collider (I have to because the ball has too many polys for a mesh collider) . Using a sphere primitive (rather than model) does scale perfectly, but I need a particular poly and UV layout so I can't do that. The problem is repeatable even with the simplest test app, so it may be a physics bug, or just another episode in the "weird stuff happens when you scale geometry" story :)
$$anonymous$$atamari, lol, one day I'll have an original idea! ;)
I just tested the scenario with a simple test script but couldn't reproduce the jerky movement that you are experiencing. Did you try to use only default assets and see if the problem persists? (just to remove some points of failure)
[RequireComponent(typeof(Rigidbody))] public class move : $$anonymous$$onoBehaviour { private float scale = 1;
void Update()
{
Vector3 move = Vector3.zero;
if (Input.Get$$anonymous$$ey($$anonymous$$eyCode.W))
{
scale = $$anonymous$$athf.$$anonymous$$ax(scale - Time.deltaTime, 0.1f);
transform.localScale = Vector3.one * scale;
}
if (Input.Get$$anonymous$$ey($$anonymous$$eyCode.A))
{
move += Camera.main.transform.TransformDirection(Vector3.left);
}
if (Input.Get$$anonymous$$ey($$anonymous$$eyCode.S))
{
scale += Time.deltaTime;
transform.localScale = Vector3.one * scale;
}
if (Input.Get$$anonymous$$ey($$anonymous$$eyCode.D))
{
move += Camera.main.transform.right;
}
move.Normalize();
rigidbody.AddForce(100 * move * Time.deltaTime, Force$$anonymous$$ode.Acceleration);
}
}
Thanks, $$anonymous$$, that's very similar to what I'm doing, but are you importing a model or using a Unity sphere? As mentioned, it scales O$$anonymous$$ for me with a Unity primitive. But the fact that this is working for you too makes me wonder if there's something about the 528-tri model I'm using that Unity doesn't like.(Even though I'm using a Unity sphere colllider) I'm going to try a few alternative spheres, see if it makes any difference. If not, I'll post a simple test scene with my geometry.
O$$anonymous$$, apologies, I should have tried this before posting, but re-modeling the sphere has cured it. $$anonymous$$ust have been some bad vertex data lurking somewhere. But thanks again, $$anonymous$$, without your confirmation that it should work, I would never have suspected the model as it was basically a Cinema4D primitive that appeared fine in every other way.
no worries, glad it works now! But I still find it extremely strange, that your mesh that you used only for rendering can affect the physics behavior in any way - even though you are using a default sphere as collider. would be interesting to understand what misconfiguration caused the hickups.
Your answer
Follow this Question
Related Questions
Ball Doesn't Roll Down Hill - Physics Problem 3 Answers
Create a "free" rolling ball controlled by player 1 Answer
Simulating the graphics of a rolling 3D ball in a 2D game 2 Answers
How to make a "pressure sensor" of sorts that when rolled over switches to another scene 2 Answers
Ball jump on collision problem 1 Answer