x


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

more ▼

asked Sep 22 '11 at 09:21 AM

FourSheds gravatar image

FourSheds
391 22 25 34

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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 ;)

more ▼

answered Sep 22 '11 at 09:48 AM

Tommynator gravatar image

Tommynator
381 3 4 11

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 :)

Katamari, lol, one day I'll have an original idea! ;)

Sep 22 '11 at 10:21 AM FourSheds

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 : MonoBehaviour { private float scale = 1;

void Update()
{
    Vector3 move = Vector3.zero;
    if (Input.GetKey(KeyCode.W))
    {
        scale = Mathf.Max(scale - Time.deltaTime, 0.1f);
        transform.localScale = Vector3.one * scale;
    }
    if (Input.GetKey(KeyCode.A))
    {
        move += Camera.main.transform.TransformDirection(Vector3.left);
    }
    if (Input.GetKey(KeyCode.S))
    {
        scale += Time.deltaTime;
        transform.localScale = Vector3.one * scale;
    }
    if (Input.GetKey(KeyCode.D))
    {
        move += Camera.main.transform.right;
    }

    move.Normalize();

    rigidbody.AddForce(100 * move * Time.deltaTime, ForceMode.Acceleration);
}

}

Sep 22 '11 at 10:59 AM Tommynator

Thanks, Thomas, that's very similar to what I'm doing, but are you importing a model or using a Unity sphere? As mentioned, it scales OK 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.

Sep 22 '11 at 12:38 PM FourSheds

OK, apologies, I should have tried this before posting, but re-modeling the sphere has cured it. Must have been some bad vertex data lurking somewhere. But thanks again, Thomas, 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.

Sep 22 '11 at 12:53 PM FourSheds

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.

Sep 23 '11 at 01:51 AM Tommynator
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1880
x199
x169
x59
x55

asked: Sep 22 '11 at 09:21 AM

Seen: 2231 times

Last Updated: Sep 23 '11 at 01:51 AM