Create a brand new script Name it any factor you need, I named it “ReseatingPlayer” after which previous the next code into it:
public static ReseatingPlayer occasion;
[SerializeField] personal Rework playersParent;
[SerializeField] personal Rework redPlayer;
[SerializeField] personal Rework bluePlayer;
[Space(10)]
[SerializeField] personal float redPlayerStartX;
[SerializeField] personal float bluePlayerStartX;
personal Vector3 playersParentStartPosition;
personal void Begin()
{
occasion = this;
playersParentStartPosition = playersParent.place;
}
public void ResetPlayers(float delay)
{
Invoke("ResetPlayersPositions", delay);
}
public void ResetPlayersPositions()
{
redPlayer.localPosition = new Vector3(redPlayerStartX, 0, 0);
bluePlayer.localPosition = new Vector3(bluePlayerStartX, 0, 0);
playersParent.place = playersParentStartPosition;
}
Now connect the script to gamers mother or father assign the values to it like I did:
redPlayerStartX: assign pink participant begin X place to it.
bluePlayerStartX: assign blue participant begin X place to it.
How you can re seat participant:
if you would like delay this do it like: 4 implies that re seat participant after 4 secs.
ReseatingPlayer.occasion.ResetPlayers(4);
if you do not need any delay:
ReseatingPlayer.occasion.ResetPlayersPositions();
I hope this can do the job.