How can I do a custom script to random detect and select a GameObject with the aspect “Point” ?
I’m using Rain Indie and I want to create the custom script in C#.
Hope someone knows how to do that.
How can I do a custom script to random detect and select a GameObject with the aspect “Point” ?
I’m using Rain Indie and I want to create the custom script in C#.
Hope someone knows how to do that.
You could create an array of possible GameObject
s, and select one from it randomly using the following code:
public class MyClass : MonoBehaviour {
public GameObject[] possibleChoices = new GameObject[0];
public GameObject getRandomGameObject() {
return possibleChoices[Random.Range(0, possibleChoices.Length)];
}
}
just be sure to populate possibleChoices
with the GameObjects you want to be available in the inspector.