Search Unity

Bounds on uninstantiated GameObjects

Discussion in 'Scripting' started by Leviathan1753, Apr 27, 2015.

  1. Leviathan1753

    Leviathan1753

    Joined:
    Feb 15, 2014
    Posts:
    13
    So, two questions:
    1) Bounds are not accurate on uninstantiated game objects, so is there another alternate unofficial way to get it that's more built in? So far I've been "recreating" the bounds myself using the collider properties and manually constructing my own bounds.

    2) To properly manually construct the bounds, I need to apply a gameobject's rotation to the bounds. Is there a function I'm missing to rotate Bounds?

    Thanks!
     
  2. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    3,201
    Bounds are axis aligned bounding boxes, it's not possible to rotate them.
     
  3. Leviathan1753

    Leviathan1753

    Joined:
    Feb 15, 2014
    Posts:
    13
    Hey Groz,

    Yeah, I suppose my #2 was phrased poorly. Obviously bounds themselves cannot be rotated... but if I constructed a bounds from a collider, it's essentially a box. I'd be after rotating that theoretical box to the rotation of the parent game object, and retrieving the new bounds that box then took up. So if the bounds was 0.3, 1, 0.3 with a parent GO z rotation of 90, it would result in something like 1, 0.3, 0.3. If it was 45 degrees it would be something around 0.6, 1, 0.6 or whatever, etc.

    Either way, I'm really after answering #1, as I feel like this would be something the community does fairly often and might have a tried and proven method.