Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Scaling a ring object?

Discussion in 'Editor & General Support' started by Kobus, Jan 1, 2016.

  1. Kobus

    Kobus

    Joined:
    Mar 27, 2015
    Posts:
    48
    Good day

    In a Unity game I require circular rings which I need to be able to scale dynamically. With this I mean I need to be able to scale the inner diameter and outer diameters individually. I have created a 3D ring model using Blender.

    The rings will be parent objects for other game objects (which I named tokens) which the player can switch on (is displayed) or off (is not displayed) as required. The width of the rings depends on the number of tokens that the player has specified and the inner and outer diameters depend on which ring it is in the concentric sequence of rings. Two of the uploaded pictures (Rings A.png and Rings C.png) shows this.

    Currently what I am doing to simulate the rings is to use two round disks for each ring. The two disks have the same centres, but the inner one has a smaller scale. I add the same texture to the inner disk as to the background to try and make the inner disk blend in with the background. I can then individually scale the two disks to the correct dimensions. One problem with this is that I need to offset the two disks slightly in the vertical aspect otherwise the colour of the outer disk appears through on the inner disk if they are at exactly the same coordinates. (Not sure if my explanation is clear here). The uploaded picture "Render issue" might make it a bit clearer.

    I am hoping there is a way to use the ring that I have created instead of the two disks. Would I be able to use the ring and scale it as I mentioned in the first paragraph? Can anybody assist?

    Kind regards.
     

    Attached Files:

  2. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    8,985
    You aren't really going to be able to scale it as described, as you would need to modify the geometry, it's not scaling at that point.

    You could use a blend shape, but that would be pretty limiting and probably overly complex. I would just generate the mesh dynamically. Since it is just a circle, it would be pretty simple, and building mesh like that is very cheap performance wise. I would recommend that route.
     
    hippocoder likes this.
  3. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I suppose a workaround would be to create a skinned mesh with 2 bones: the inner verts bound to bone 1 and the outer verts bound to bone 2.

    This allows you to scale each bone individually thus retaining control over the fatness of each ring.
    You can access the bones in Unity by simply locating them in the hierarchy and scaling them.
     
  4. Kobus

    Kobus

    Joined:
    Mar 27, 2015
    Posts:
    48
    Hi hippocoder
    Thank you for this. This sounds like what I will need for my next project. Will explore this.
    Regards.
     
  5. Kobus

    Kobus

    Joined:
    Mar 27, 2015
    Posts:
    48
    Hi zombiegorilla
    Thanks for the advice. I managed to create a ring shaped mesh and I can implement it in my project.
    The color difference between the ring mesh and a built-in primitive just baffles me a bit.
    I have uploaded a screen shot of what I mean. The ring mesh appears very white and the primitive cylinder (created from the list of 3D Objects n Unity) much more grey. I have added exactly the same standard shader to both of them.
    This is annoying because in my project I add cylinders to the ring mesh and they need to be the same color as the ring mesh. See picture 2: The darker green circles should be the same color as the light green ring.
    What am I missing here?
    Regards.
     

    Attached Files: