Hey, all,
Come up with a bit of a problem I don’t seem to be able to get over, and I was wondering if any of you could help?
I have a group of objects, all parented together (that bit isn’t important), none of which have colliders or rigidbodies attached (for performance purposes).
They are covered by a “hull” collider (a sphere), on which they all sit pretty close to the edge.
The objects within the collider are of different sizes - some of them significantly bigger than the other objects.
What I want to do is detect a collision on the Hull, and then choose and perform functions on the closest object to the hit point.
Finding the hit point is a breeze, but due to the differences in size of the objects within the hull collider, I can’t seem to pick the correct object from within all the time.
I do a simple radial distance check on every object that’s within the hull, like so:
Distances[i] = Vector3.Distance ( ObjectPos[i], CollisionPoint );
The problem being that this measures the distance to the centre point of the object, rather than the closest point on the object, which means that, if I have an impact point which is on, but close to the edge of a large object, which is adjacent to a small object, the small object is always chosen as the closest, even though the point is actually on the larger object.
All of the systems Unity provides (that I’m aware of) for testing this type of thing rely on a collider and\or rigidbody being present, but I can’t add these for performance purposes (the game is for iPhone), and I really don’t want to be getting down and dirty trying to check the distances between vertices to sort this out, as I think that’d be too slow too, so, has anyone got any ideas?
If any of that isn’t clear, please let me know - this looks like the last hurdle before completion!
Cheers,
SB