Hello everyone.
I have a cube mesh, which is supposed to be a trigger for some actions, when a walking character overlaps it. Quite Simple. The trigger mesh has its x,y,z, rotation and scale changed somehow.
I tried to use something like this:
if(mesh.worldBounds.overlaps(char.worldBounds)){...}
It works, but the bounds are placed incorrectly (I don’t understand how exactly, but not like the cube itself).
Then I tried a simpler method - to test if a single point is inside the bounds:
if(mesh.worldBounds.containsPoint(char.position){...})
But it seems to be working with the same incorrect bounding box.
Then I came up with something weird, which relies on bounds property, but first I need to translate char.position to bounds-space:
vec:Vector3D = mesh.inverseSceneTransform.transformVector(char.position);
if(mesh.bounds.containsPoint(vec)){...}
To my surprise it worked correctly, however I wasn’t even sure, if I multiplied position by the correct matrix XD. But my problem now is that I still want to use overlaps() method and I don’t know how to translate char.bounds to mesh.bounds space for that. And I am still thinking, that I did something incorrect with worldBounds property.
Did anyone have a problem like this one? Is it a bug with worldBounds?
By the way I used mesh.showBounds = true; And in all cases it shows the correct bounds, as expected.