Founded Unity criticism

I’ve discovered that Unity has a lot of faults/lacks for a commercial engine at version 3.5 (In this post I will only comment this concrete problem).
One of the most disapponting ones is the improper results of the function Rigidbody.ClosestPointOnBounds().

First, the proofs:
1.- Create a cube at (0,0,0) with rotation=(0,0,0), scale=(1,1,1) and attach a rigidbody component
2.- Create a empty game object (name it “son”) and make it son of the cube. Assign it the local position (1.5, 0, 0)

At this point the distance between “cube” and “son” is exactly 1.

5.- Add this script to “cube”

function Awake()
{
	var go : GameObject = GameObject.Find("son");
	if (go == null) print ("error !!!");

	var pos : GameObject = new GameObject ("pos");
		
	pos.transform.position = transform.rigidbody.ClosestPointOnBounds (go.transform.position);
}

6.- When running, it spaws a new (and empty) GameObject (“pos”) in correct the position: At (0.5, 0, 0) as it should do.

7.- From the editor, go to “cube” and rotate it about Y axis 45 degrees. Now “son” is at the correct position but “pos” IS NOT.

The reason is that a commercial engine at version 3.5 doesn’t supports OBB (Oriented Bounding Boxes), only AABB (Axis Aligned …).
After crawling the forums/answers I found this is a well known, old and never solved problem of Unity since at least March of 2009 (http://forum.unity3d.com/threads/29321-question-about-boxcollider(axis-aligned-gt-oriented-alig).
The developers claim that it’s difficult to find and algorythm to work with OBB, but even FREEWARE engines as Ogre3D implement it.

There is a fast and easy (although cheesy) solution wich dont needs any complex OBB algorythm:

Every object with a collider attached could automatically generate the 8 vertices of the OBB implemented as empty GameObjects being sons of the object with the collider attached and excluded from hierarchy window to make them invisible for the user.

  • The calculation of the local position of these vertices is trivial because they are orthogonal to local (0,0,0).
  • When the object is rotated/translated the vertices are shifted correctly because they are sons of the rotated/translated object.
  • The position in the world of the vertices is also trivial: verticeName.transform.position
  • The construction of the OBB having its 8 vertices is also trivial.

This would result in a minor RAM sacrifice (only the objects with collider/rigidbody attached would need them), and would allow to have OBBs:

  • Better collision detection
  • Know the dimensions of a object in runtime and consequently easy calculation of OBBs for complex objects
  • Functions as ClosestPointOnBounds() would work properly
    and many other problems derived from lacking of OBBs would be solved.

So, as Sheldon Cooper’s mother would say:
“Put down that Pepsi can full of bourbon that ain’t foolin’ no one, and start coding.” :stuck_out_tongue:

Uhm, dunno what are these bb so useful for but agree.

My biggest problem at the moment , is that unity does not allow one to rebake a single selected object without fn the entire scenes lightmapping up. Instead, unity decides that if your only going to bake one object, it will mess all your other objects lightmaps up.

Yep, Beast workflow is… “bad” to be gentle.
And not only the workflow.

Megmaltese, can you see now the implications of using AABB ? Think for example in collisions, object selection, etc…
When you apply a rotation not multiple of 90 degrees, the AABB is bigger than needed.

Code your solution up and sell it on the asset store.

It should be done at engine level not as a prefab.

BTW, it is unacceptable to sell a patch for a faulty product.
I already contributed to Unity discovering a bug and giving a possible solution.
Unity costs 1000 bucks, for that price they should include a lot of things more than they do,
but that’s another history.

A few things to clarify here…

The person who mentioned looking for an OBB algorithm was me and while I work at Unity, I am not actually a developer. The OP was actually asking for an algorithm to find a best-fitting OBB for an arbitrary mesh, which is much more complicated than simply changing the orientation of an already known bounding box (which, as you have correctly noted, is straightforward). My comment about looking for an algorithm referred to the fact that it was not easy to find an algorithm suitable for a short coding example that I would have time to implement.

My point, really, is that this is not some kind of failure on the part of the developers, it’s just a confusion of two different issues.

Also, the choice of bounding box type is not in any sense a bug or fault and it is rather inflammatory to suggest that it is. If the inaccuracy of the AABB is a problem for you then you are welcome to request OBB as a feature. However, there is nothing about the definition of the ClosestPointOnBounds function that suggests that it should necessarily use an OBB.

Hi Andeeee!

First, thanks for answering. Second, I’m not trying to flame, only to help to solve an OLD problem.

We can discuss (or not) about OBBs, but the fact is that Rigidbody.ClosestPointOnBounds() doesn’t works properly in all the cases.


The problem is that if you have an object not like an sphere **ClosestPointOnBounds()** returns a point quite far from the mesh, so it would be useless is most of the cases. As “longer” is the object, the greater the distance to the mesh.

Your point appears to be changing the logical sense of the function to avoid implementing OBBs.
If you ask unity users where is the Closest Point to the Bounds of the cube, I bet nobody will say it
is where ClosestPointOnBounds() say it is.
If you want to do that, you should include it explicitly in the docs to avoid the misunderstoods.

By the way, OBBs are not so hard to implement as you say:
http://www.ogre3d.org/tikiwiki/Oriented+Bounding+Box&structure=Cookbook
As you can see, it’s straightforward having an AABB (160 c++ lines including code to render the box which is unnecessary); so, the solution is less than 50 code lines. Who needs 3 years to code it ?

Yes, this needs to be fixed asap. Why should I have to implement basic collision tests when I’m paying $1500 a seat?

This is kind of off-topic, but relates to criticism to Unity Technologies. I’ve tried several examples and tutorials and several of them have errors in them. 2 really bad ones are:

-Character Customization tutorial: Characters do not spawn when user chooses to BUILD and play the game for dressing room and virtual world. There’s a forum post to this issue, which is dead with no replies from anyone from Unity Technologies
-iPhone-Match tutorial, the card game: it does not work when loading and pressing Play in editor
-Platform 3d Lerpz tut: when Lerpz respawns from a robot death, he flies off the spawnpoint
-2D Tutorial: there are spaceship collision anomolies with the top platform

This was to andeeee

Your antagonistic response towards a customer (whether he pays for pro or not) is unfortunately quite representative of game engines hiding behind the “indie” badge.

And it is a Bug. If you are going to render the BB representation as an OBB in the scene view, it should be performing intersection tests on an OBB, not on some invisible AA version of the BB. And there’s nothing in the API docs for ClosestPointOnBounds that tells anyone anything about what it does or does not do! The trifecta of: (1) a lack of basic features, (2) API that suggests the features exist, and (3) lack of documentation for this API. I would say it needs to be addressed, and not via a “feature request.”

Does it not make sense that majority of potential license buyers will not buy it with faulty learning material? Faulty learning material insinuates faulty game engine, simple as that.

Why not just create a cube mesh, and then use a mesh collider with your object, and set the mesh on the mesh collider to the cube mesh?

OK, more clarification is evidently needed here.

The implication of the OP is that oriented bounding boxes are a major missing feature that was reported years ago and yet the developers of Unity have never done anything about it because they consider it too hard to implement. With this interpretation, Unity would appear to be very lazy since algorithms for OBBs are easy to find and implement. However, there are several levels of misunderstanding here.

The thread that supposedly “reported” the lack of OBBs was actually looking for a more complicated feature, namely calculating a best-fitting oriented bounding box around a given set of vertices. This is much harder to implement well (see here for details) and probably not a high priority feature for most people. What I said in that thread was that implementing a best fitting bounding box algorithm would take more time than I could justify spending on it just for a single support case. However, this has been misinterpreted to mean that Unity’s developers couldn’t be bothered to find a simple OBB algorithm. I am not on Unity’s development team and the algorithm I was talking about was something completely different.

Really, anyone who names a thread “Founded Unity Criticism” and uses derisory language to complain about a “well known, old and never solved problem of Unity” should expect the company to justify itself when the criticisms are actually false.

The real issue here is whether Rigidbody.ClosestPointOnBounds would be better if it used OBBs and I’m inclined to agree that it probably would be. However, there doesn’t appear to be anything in our bug database or feedback system about this function. This would suggest that this is not a glaring omission from Unity so much as a little-used feature that could be improved. We are happy to accept feature requests from anyone but as far as we know, this is the first time anyone has requested an improvement to this function (the thread referenced by the OP was about a completely different thing). As I have already said, if improvements to ClosestPointOnBounds are something you would really like then by all means file a feature request. The bottom line, though, is that this is not some well-known and high priority bug that we are simply too lazy to fix.