- Home /
Question by
arashsh · Feb 12, 2020 at 07:05 PM ·
transformcharacterchild objectfor
How Set a Rotation Of Child GameObject For Character Selection
Hi, i have a scrip for make characters selection but when character selected in new scene when character selected get active rotation back to zero! sorry for my bad english
private GameObject[] playerlist; private int index; private int playerint = 1;
void Start()
{
index = PlayerPrefs.GetInt ("playerselect");
playerlist = new GameObject[transform.childCount];
//childCount
// Fill the arry with models
for (int i = 0; i < transform.childCount; i++)
{
playerlist[i] = transform.GetChild(i).gameObject;
transform.GetChild (i).Rotate (-90.0f, 0.0f, 0.0f);
}
// toggle off renderer
foreach (GameObject go in playerlist)
{
go.SetActive(false);
}
Quaternion[] childRotations = new Quaternion[index];
// turn on selected player
if(playerlist[index])
{
playerlist[index].SetActive(true);
}
}
public void SelectPlayer()
{
PlayerPrefs.SetInt("playerselect",index);
}
Comment
Your answer
Follow this Question
Related Questions
Need help getting my character to move 2 Answers
How Should I Get a List of Child Objects 2 Answers
Character Transform 3 Answers
Instantiating a new gameObject as a child of a different gameObject 2 Answers
Destroying & Then Spawning Quickly 1 Answer