Hi, I have a code that works perfectly but the code is long I have written the same code for each player is there a possible way to make a list of players and don’t need to write the code again, I’m a beginner.
public GameObject playerPos, playerPos2;
private Vector3 playerResPos, playerResPos2;
public GameObject restPos, restPos2;
private void Update()
{
playerResPos = restPos.transform.position;
playerResPos2 = restPos2.transform.position;
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.CompareTag("Player")
playerPos.transform.position = playerResPos;
playerPos2.transform.position = playerResPos2;
}