Samsung / GearVRf

The GearVR framework(GearVRf) is an Open Source VR rendering library for application development on VR-supported Android devices.
http://www.gearvrf.org
Apache License 2.0
407 stars 217 forks source link

Problem with setScale() and collider detection #2028

Open SteveGreatApe opened 5 years ago

SteveGreatApe commented 5 years ago

I've got an object in my scene where I control it's size using setScale. I've also got a Collider on this object. I've found I'm having problems getting the pickers nearest object detection to work when this object is in front of another object with a Collider.

What I think is happening is that the calculated distance used to determine the nearest object is also getting mapped by the scale. So for instance if an object is 2 units away, and has a scale of 0.5, then the distance gets divided by 0.5 giving a total of 4, which is the effective distance allowing for scaling.

So if there's another object 3 units away with a normal scale of 1, this gets given a distance of 3 so the Picker thinks it's nearer and returns a hit on this object, not the scaled object that is actually closer.

mpolsz commented 5 years ago

We had similar problem in our app. What we found out is that MeshCollider returns distance for raycast in mesh coordinates not in world (Sphere and Box colliders returns distance in world coordinates). I made quick fix in our fork #2033 but someone from core team should look into this issue.

liaxim commented 5 years ago

@NolaDonato Please take a look