objects of same parrent random scale/size(xy and z)
I have objects that are collectibles, I want them too have a different scale or size I am having problems understanding the difference but basically if i have 5 of these spheres next too each other i want them all too have a different scale/size on the xyz axis that would look like (3, 3, 3) or (0.25, 0.25, 0.25)
preferably in a "minScale" value and a "maxScale" value
this script is on a empty parent object that has this script on it and 2 objects which makes up the "sphere"
this is what i currently have (it does not work at all) using System.Collections; using System.Collections.Generic; using UnityEngine;
public class SizeMod : MonoBehaviour {
Set minScale = 0.25;
Set maxScale = 2;
GameObject (GameObject source, float minScale, float maxScale);
void Start ()
{
transform.localScale *= Vector3.one. * Random.Range(-minScale, maxScale);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class transformscale : $$anonymous$$onoBehaviour {
public float $$anonymous$$Scale = 0.25f;
public float maxScale = 2f;
private float randomized;
void Start()
{
randomized = Random.Range($$anonymous$$Scale, maxScale);
transform.localScale = new Vector3(randomized, randomized, randomized);
}
}
so after i finally got a $$anonymous$$cher to look at my problem we found that i was basically calling my code wrong and we just used "new vector3" ins$$anonymous$$d of vector3.one and changed out the = with the private float "randomized" then now all the collectables spawn in at random sized scales :)
Your answer
Follow this Question
Related Questions
Create random numbers of object and move them 0 Answers
function works script-wise; doesn't work visually(only in game) 0 Answers
Saving default scale of an object c# 1 Answer
Player Prefab scale automatically goes to 1 x 1 x 1 whereas I have set it to 0.48 x 0.48 x 0.48 1 Answer
random question without repetition 0 Answers