I currently have a situation where, when a button is pressed, I want to see if a character is over an object so that said character can pick up that object. This is done in 2D, and from what I’ve seen it looks like I could use some colliders with ray casting to see if they are over each other. However I also see that mesh colliders appear to be a “no no” for iphone performance.
I understand the concept, however how would this be implemented? Currently the stuff I can think of ends up going back to raycasting. I’m trying to figure something out based on 2D collision has been handled historically. Lot of learning going on.
If you know exactly what objects you want to compare positional relationships to, you can simple have the script of each have variables that reference the transform of the other(s). For instance, in Zombieville, the player script had an array that contained references to all of the transforms of the currently active Zombie objects in the scene. Check collision for the purposes of determining if a melee attack connected, or if the enemy should attack you, was just a matter of iterating through the array, comparing transform values (if myTransform.position.x - yourTransform.position.x < minimumDistance) and thus determining if the other object is within range.
If possible, use built-in arrays for these kinds of comparisons (as opposed to javascript arrays, which are much slower), and only check collision when absolutely necessary. Looping through a list of transforms could be expensive if you get too crazy with it, but are typically far more efficient than character controllers and raycasts.