Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Scaling ARSessionOrigin moves the object vertically

Discussion in 'AR' started by bkg2012, Mar 19, 2019.

  1. bkg2012

    bkg2012

    Joined:
    May 25, 2016
    Posts:
    6
    I have an object in my game that I would like the player to freely scale as he pleases. After trying a lot of different approaches my code eventually settled like this:

    Code (CSharp):
    1. public void OnScaleSliderValueChanged(float value)
    2. {
    3.     var scale = minScale - value * (minScale - maxScale) / 100f;
    4.     arSessionOrigin.transform.localScale = new Vector3(scale, scale, scale);
    5. }
    And here is how it actually behaves:



    The issue here is that the object does not only scale but it also moves vertically. Is there any clever way (without manually changing the object's Y axis) to force it to stay on the ground?
     
  2. GreeneMachine

    GreeneMachine

    Joined:
    Jul 3, 2015
    Posts:
    126
    Hi

    Is the object actually "moving" up in Y? Or are you just seeing the effect of scaling... but the pivot point is staying locked to its position? Can you move your device down to a side on view before and after scale..
     
  3. bkg2012

    bkg2012

    Joined:
    May 25, 2016
    Posts:
    6


    Honestly, I have no idea what's going on. As it seems the scaling is working perfectly when looking at the object from the side but the moment I get up it starts going up as well.
     
  4. GreeneMachine

    GreeneMachine

    Joined:
    Jul 3, 2015
    Posts:
    126
    I noticed the tracking moved... assuming that's all setup ok, maybe try place your object on a surface with more detail, just to be sure you're not loosing tracking when you are getting up in that example.

    As far as looking down on the object, I think the "illusion" is its moving up, but its just scaling in the frame... not getting closer (Unless the pivot is at the base.. so the height of the terrain will make the highest point move up.. but the pivot stays at 0

    That's what it looks like to me.. again, assuming all else is setup and working ok
     
  5. Briocheuh

    Briocheuh

    Joined:
    Jun 21, 2019
    Posts:
    1
    Hello,

    I know your post is a bit old but I have exactly the same problem. Did you find a solution to it or is it the tracking not working well?

    Thanks in advance!