2

today I updated my project to version 2017.2.0f3 (was working on 2017.1.1f1 before).

This...

offsetX = objectCollider.bounds.extents.x;

...used to return the bounds in world space of my SphereCollider, but now it only returns the radius of the component. The documentation says it should return the bounds in world space.

The radius of my SphereCollider is always the same while the whole GameObject is rescaled. Every method that used to return the right value before the patch now just returns the radius that can be set in the inspecor for example.

Am I missing something, is this a bug or was this changed since the last patch? I'm a bit lost on this one.

Foggzie
  • 9,691
  • 1
  • 31
  • 48
Pft
  • 23
  • 3

1 Answers1

1

This hasn't changed recently. The bounds property of a Collider returns a Bounds object in world space, as documented. From a Bounds object, you can use the center property to get its world space Vector3 location but you're looking at the extents property which will give you information regarding its size so those values are in local space.

If you want the x component of the collider's bound's world space information use:

objectCollider.bounds.center.x;

If you'd like the world space coordinates of the collider's bounds, you need to combine its center property with the size information you get from the extents property.

Foggzie
  • 9,691
  • 1
  • 31
  • 48
  • Yes, *.*.center will return the position in world space, but I need the extends or the size of the collider in world space. This does not work like it used to in the previous patch.. I just get the radius (size in local space) – Pft Nov 07 '17 at 09:29
  • @Pft The `extents` object is just a size. You can use that and combine it with the the `center` property to get world-space coordinates. This has never changed in Unity. – Foggzie Nov 07 '17 at 18:28