I have an Object(parent) having 4 spawn points around it which spawns stars. In the game, Parent object rotates but the Spawned stars don’t move according to Parent objects rotation. I have tried all the suggestions people have given in the forum.
public GameObject starPrefab;
private GameObject newStarPrefab;
public Transform[] starSpawnPoints;
void Start () {
if (!GameObject.FindGameObjectWithTag("Box"))
{
RandomPoint();
}
}
void RandomPoint()
{
int randomIndex = Random.Range(0, starSpawnPoints.Length);
for (int i = 0; i < starSpawnPoints.Length; i++)
{
if (randomIndex == i)
{
newStarPrefab = Instantiate(starPrefab, starSpawnPoints*.position, Quaternion.identity);*
newStarPrefab.transform.parent = gameObject.transform;
}
}
}
I have added this script to the Parent object which rotates after spawning.