Search Unity

Beginner question about activating UI - elements

Discussion in 'Scripting' started by scythwolf, Apr 3, 2019.

  1. scythwolf

    scythwolf

    Joined:
    Dec 30, 2018
    Posts:
    49
    HI!

    Sorry if I ask a newbish question but I am pretty new to unity. This is my 2nd project and my 1st one with scripting involved.
    My actual project is about a medical 3D application. At its core there is a basic abstraction of the bones to show a pathological posture of a patient by adjusting the bones according to a webcam input.
    For doing that I need to be able to scale the bones. After watching and redoing some tutorials and playing with the coding I am familiar with scaling, moving, rotating objects using an UI (I will use sliders I think).
    Now my main issue is how to scale properly for this project: For example my feet consists of 2 parts - thigh and lower leg. Let's say one has a bigger right lower leg. That means I need to scale that lower leg along the y axis but only the upper face may move up since the lower part of the lower leg should needs on the floor.
    At first I thought I could stick with setting the original to the lowest face - but some people have legs where one side is not as big as the other one... in this case I need to move the lower face up!

    Here is the super basic sceleton I will start out with and to show what I mean with 'upper face moving up' by scaling the object.
    upload_2019-4-3_15-34-15.png

    Thanks for any hints in advance.
     
  2. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,748
    Objects are scaled relative to pivot. Place pivot at center and after scaling update position to be half length from the prev bone size. But I suggest you'd create model from connected points, scale it, and then resize colliders to fit in between points of the model. This sounds more complicated, but actually is easier since model and view calculations are separated.
     
    scythwolf likes this.
  3. scythwolf

    scythwolf

    Joined:
    Dec 30, 2018
    Posts:
    49
    Thanks for your hint. I will think about that as well. For now I took a rigged skeleton. Since the rig does a lot on its own I get already pretty far with it. So happy that I can change the rig only with some lines of code :)
    Unity is awesome.