Search Unity

"Rolling" balls

Discussion in 'Editor & General Support' started by DaveyJJ, May 14, 2005.

  1. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,558
    aarku/joe/nicholas et al ....

    I have a sphere/marble in my maze demo that isn't rotating when I apply the SmoothParentRotation script to it. Does the marble need to be a child of an empty object for the rotation to work when it rolls?

    david
     
  2. Jonathan Czeck

    Jonathan Czeck

    Joined:
    Mar 17, 2005
    Posts:
    1,713
    The SmoothParentRotation script looks at the object's parent and then gradually matches its rotation to it. If the object doesn't have a parent, or the object's parent doesn't have a Transform component, you'll get an exception. (which is bad)

    I'd guess that what you are wanting to do instead is add a RigidBody component to your marble and a SphereCollider component. Then you'd probably want to add a MeshCollider component to your "maze", so that the marble has something to collide against. This way the physics engine will handle all the "rolling" for you.

    If this doesn't sound like what you want, could you perhaps explain a bit more what you're up to?

    Cheers,
    -Jon
     
  3. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,558
    Actually, I've done that and when my seven year old and I looked at it in both game view and world view, we noticed that the marble/sphere is actually rotating/rolling correctly. I can actually watch the XYZ axis arrows rotating around.

    The problem appears to that the texture I've applied to the sphere is not rotating along with the sphere ... as if the texture isn't glued or wrapped on the surface of the marble but rather is surrounding it and not being moved by the sphere's turning.

    So the question I guess is how do I fix the texture on the sphere so that it shows the sphere actually rotating?

    David (and Cal who is now in bed)[/b]
     
  4. Jonathan Czeck

    Jonathan Czeck

    Joined:
    Mar 17, 2005
    Posts:
    1,713
    In the material inspector of your marble, set the Shader to something like Diffuse and click on the Base texture map. From here you'll probably want to change the Coords to Object Space or UV (if you have a UV mapped object), and fiddle with the other things until you have it looking how you'd like. Did you by chance have it set on Eye Space? That'd give the result that you are describing.

    HTH,
    -Jon
     
  5. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,558
    OK, got it working now by making the coordinates UV. they were previously set to Object Space and definitely not working for some reason, probably operator error :wink:

    David
     
  6. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    Object space UV coordinates are going out (together with all other generation options in the next beta.

    Only thing left will be a scale bias to be applied to the coordinates