Search Unity

offset issue, small float value turns into large integer

Discussion in 'Editor & General Support' started by LiamMedaphor, Oct 23, 2018.

  1. LiamMedaphor

    LiamMedaphor

    Joined:
    Oct 22, 2018
    Posts:
    1
    Hi all, I am working on a project where I am creating an offset from a given point by the image height/2 (placing the image directly below the given point). I have wrote a method to get the height using the box collider y value /2 and this gives me the correct value, however when i apply this value to adjust the transform what would have been something like 2.13 ends up moving my gameobject by 213 units.

    the following code as an example;
    this.transform.position = new Vector3(this.transform.position.x, this.transform.position.y -1, this.transform.position.z);

    where as it looks like the object will only be offset by -1 unity, it actually offsets the object by 100 units.

    EDIT:

    I solved this by adding a parent object and setting the scale to 1, I then added a box collider and used the bounds.extents to give me the height of the box collider with scaling multiplications applied.
     
    Last edited: Oct 23, 2018