How to use a randomobject script on walls?

I want to randomly place a poster I made on the walls in my game. My teacher showed me a randomobject script, but it just places the selected model randomly throughout the Terrain. How could I edit this so it randomly places a cube with this texture, but only on walls (or the mesh collider on them)?

Good day.

I think you are little lost… “randomObject script” is nothig in Unity, i supose your teacher created a script called like this, which have some functions to instantiate a random object.

IF you want to do something random, you need to use the function

Random.Range (min, max);

Lets say you want a number between 0 and 100. Every time this code is executed, the variable “NumberRandom” will be a number between 0 and 100:

int NumberRandom = Random.Range(0, 100);

This way you can use this to position a object in worldspace, or Instantiate a random object from a list, for eaxmple, lets say you hav an array of 5 objects, and need to instantiate one of them.

Instantiate (ObjectsArray[Random.Range(0,ObjectsArray.Length)], position, Rotation);

This will instantiate a random object from your ObjectsArray at “position” and “rotation”.

If helped, accept the answer and close the issue :smiley:

If not, give more info!