I’m new to this, making my first simple game for practice. I’m getting the spawning that I want, but rather than have the rotation defined by my spawn points, I’d like the Z component of rotation to be randomized. This is where I am at right now, just need to know how to get that “randomZ” int into the spawnPoint.rotation.
// Find a random index between zero and one less than the number of spawn points.
int spawnPointIndex = Random.Range (0, spawnPoints.Length);
// Find a random index between zero and one less than the number of star types.
int starTypeIndex = Random.Range (0, starType.Length);
// Find a random index between 0 and 360 for random rotational position of star around z axis.
int randomZ = Random.Range (0, 360);
// Create an instance of the startype prefab at the randomly selected spawn point's position and rotation.
Instantiate (starType[starTypeIndex], spawnPoints[spawnPointIndex].position, spawnPoints[spawnPointIndex].rotation);
TBruce
2
Is this what you are looking for?
Quaternion rotation = Quaternion.Euler(Random.Range(0, 360), (Random.Range(0, 360)), (Random.Range(0, 360)));
// Create an instance of the startype prefab at the randomly selected spawn point's position and rotation.
Instantiate (starType[starTypeIndex], spawnPoints[spawnPointIndex].position, rotation);