# Unity - Place Objects at Random Location - Select certain once to fade in or out.

edited
Hi guys.

Any tips how I can achieve the following. I am trying to place objects in a area. Was thinking of using perlin noise. Fade them in and out according to value 0 to 1 in float value.
I want to then fade example the blue marked once out at 0.6f and then the the once marked in red at 0.3f and then all of them at 0f. Then back in according to the values.

What I want to use it for is to place 2d clouds at the points. Then fade them away or in according to how the storm / snow is being handled by my value from 0 to 1.

Have a good one!

• edited
You haven't really defined what you want, why the red ones, why the blue ones, is it important that they have X distance bewteen them, why not just actually use random.range() for the x and y values?
• Try playing with this, why does not matter if the mechanic is already defined (even if it is vague):

I can suggest a little helper for fading multiple values between multiple ranges based on a single linear input:

```// A useful helper to give you a clamped linear value of 0 at min and 1 at max.
float LinearBetween(float value, float  min, float max) => Clamp01((value - min) / (max - min));```

You can use the above helper to control the fading of all your cloud layers.
```// how stormy is the weather? (0.0 to 1.0), this is your input to control your weather.
float stormy = (some value between 0.0 and 1.0);

// these clouds begin fading in at .5, and are opaque by 0.6
var clouds1 = LinearBetween(stormy, .5f, .6f);

// these clouds begin fading in at .1, and are opaque by 0.4.
var clouds2 = LinearBetween(stormy, .1f, .4f);

// these clouds begin fading in at .0, and are opaque by 0.9
var clouds3 = LinearBetween(stormy, .0f, .9f);```

As for placement you can just use perlin noise to generate the positioning and their ranges, with time based offsets for whatever parallax effect you need post noise.
• Try playing with this, why does not matter if the mechanic is already defined (even if it is vague):

I can suggest a little helper for fading multiple values between multiple ranges based on a single linear input:

```// A useful helper to give you a clamped linear value of 0 at min and 1 at max.
float LinearBetween(float value, float  min, float max) => Clamp01((value - min) / (max - min));```

You can use the above helper to control the fading of all your cloud layers.
```// how stormy is the weather? (0.0 to 1.0), this is your input to control your weather.
float stormy = (some value between 0.0 and 1.0);

// these clouds begin fading in at .5, and are opaque by 0.6
var clouds1 = LinearBetween(stormy, .5f, .6f);

// these clouds begin fading in at .1, and are opaque by 0.4.
var clouds2 = LinearBetween(stormy, .1f, .4f);

// these clouds begin fading in at .0, and are opaque by 0.9
var clouds3 = LinearBetween(stormy, .0f, .9f);```

As for placement you can just use perlin noise to generate the positioning and their ranges, with time based offsets for whatever parallax effect you need post noise.
Great. Let me have a crack at this.

Thanks man