-
Notifications
You must be signed in to change notification settings - Fork 0
/
CharacteristicsGenerator.cs
48 lines (40 loc) · 2 KB
/
CharacteristicsGenerator.cs
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using UnityEngine;
public class CharacteristicsGenerator : MonoBehaviour
{
public GameObject BodyObject;
public GameObject HeadObject;
// Intervalos de escala para o corpo
public float minBodyWidthMultiplier = 0.9f;
public float maxBodyWidthMultiplier = 1.1f;
public float minBodyHeightMultiplier = 0.95f; // Para "achatar" o corpo
public float maxBodyHeightMultiplier = 1.05f;
// Intervalos de escala para a cabeça
public float minHeadSizeMultiplier = 0.95f;
public float maxHeadSizeMultiplier = 1.05f;
// Intervalos de escala para altura geral do personagem
public float minHeightMultiplier = 0.95f;
public float maxHeightMultiplier = 1.05f;
void Start()
{
RandomizeCharacteristics();
}
void RandomizeCharacteristics()
{
// Randomiza a largura e altura do corpo
float bodyWidthMultiplier = Random.Range(minBodyWidthMultiplier, maxBodyWidthMultiplier);
float bodyHeightMultiplier = Random.Range(minBodyHeightMultiplier, maxBodyHeightMultiplier);
Vector3 bodyScale = BodyObject.transform.localScale;
bodyScale.x *= bodyWidthMultiplier; // Ajusta a largura (eixo X)
bodyScale.y *= bodyHeightMultiplier; // Ajusta a altura (eixo Y) para "achatar"
BodyObject.transform.localScale = bodyScale;
// Randomiza o tamanho da cabeça (largura e altura)
float headSizeMultiplier = Random.Range(minHeadSizeMultiplier, maxHeadSizeMultiplier);
Vector3 headScale = HeadObject.transform.localScale;
headScale.x *= headSizeMultiplier; // Ajusta a largura (eixo X)
headScale.y *= headSizeMultiplier; // Ajusta a altura (eixo Y)
HeadObject.transform.localScale = headScale;
// Randomiza a altura geral do personagem (Body + Head)
float heightMultiplier = Random.Range(minHeightMultiplier, maxHeightMultiplier);
transform.localScale = new Vector3(transform.localScale.x, transform.localScale.y * heightMultiplier, transform.localScale.z);
}
}