First of all, "performance loss" is only an argument in situations where performance actually matters. When your framerate is good enough and your code is easier to read and maintain with colliders and raycasting, then by all means, stop fixing what isn't broken.
But in the case of a lane defense game like plants vs. zombies, you have very simplified game physics where the Unity collision detection engine indeed seems overkill.
- Objects can only collide with objects in the same lane
- When two objects are in the same lane, all that matters is the x-coordinate and the width of the objects involved.
- All objects only move in one direction and only collide head-on. So you only need to check for collisions in one direction.
First you need to know which lane each object is in. There are several ways you could do that.
- You could make each lane an own object in your scene hierarchy and all objects on that lane child-objects.
- You could have a
public int lane variable on each object which says which lane it is on.
- You could have a
List<GameObject> for each lane somewhere.
Each of these approaches has advantages and disadvantages. Pick the one which seems to fit best into your overall architecture.
If you want to check collisions of an object
obj with other objects, get all objects in the same lane. Then if you want to check for a collision to the right, do
if (other.x - obj.x) < (obj.width + other.width) / 2 for each eligible object in that lane. To check for a collision to the left, do
if (obj.x - other.x) < (obj.width + other.width) / 2.
A side-note about the Rigidbody component: You only need rigidbodies when you want to have kinetic physics (gravity, mass, friction, objects bouncing off each other, etc.). When your game isn't supposed to have anything like that, you shouldn't put a rigidbody on anything. I am not saying that adding realistic physics couldn't be an interesting spin on the overused tower defense formula, but when you want to create an authentic Plants vs. Zombies clone, you likely don't want that. When all you want is collision detection, then all you need is a Collider.