How to limit the instantiation of a prefab/object?

I will explain this in the best way I can.

I want to be able to instantiate an object(or a prefab) in a certain direction until it collides with a gameobject that has the “Wall” tag. When it hits the “Wall” gameobject I would like it to resize the object so that it will never pass through the wall.

Is this possible in any way? Any tips or hints would be appreciated too!

Thank you,
Eugen

If you keep track of your “wall” or plane as point-normal, it’s really easy (Khan academy link for the math involved). The code would look something like this:

Vector3 wallToObject = wall.position - object.transform.position;
float dot = Vector3.Dot(wallToObject, wall.normal);

if( dot > 0.0f )
    // object has passed the wall this frame, move it back and instantiate your collision object