forked from RonenNess/UnityUtils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandomScaler.cs
More file actions
34 lines (29 loc) · 811 Bytes
/
RandomScaler.cs
File metadata and controls
34 lines (29 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
* Randomly scales an object, based on position.
*
* Author: Ronen Ness.
* Since: 2018.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace NesScripts.Graphics
{
/// <summary>
/// Create random scaling based on object's position.
/// </summary>
public class RandomScaler : MonoBehaviour {
// min scale
public float MinScale = 0.8f;
// max scale
public float MaxScale = 1.2f;
// Use this for initialization
void Start () {
System.Random rand = new System.Random((int)(transform.position.x * 1234.25 + transform.position.z * 97.5 + transform.position.y));
float factor = MinScale + ((float)rand.NextDouble() * (MaxScale - MinScale));
transform.localScale = transform.localScale * factor;
Destroy (this);
}
}
}