Hi I’m trying to create a game that the user moves two characters at the same time. So in order to pass the stage both characters must be at the door. How can I make that on Unity??
This is the coding I used if one of the characters touches the door but I’ll like to make it for both characters
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class endtrigger : MonoBehaviour
{
[SerializeField] private string newlevel;
void OnTriggerEnter2D(Collider2D other)
{
if (other.CompareTag(“Player”))
{
SceneManager.LoadScene(newlevel);
}
}
}
Idk how to code at all, so i’m probably totally wrong, but wouldn’t it be something like
if (other.CompareTag("Player")) && (other.CompareTag("Player2")
Basically add 2 tags, guessing the 2nd character has to have a different tag. But again i’m a total noob so i can only guess >.< Hopefully it was helpful.
Adam thanks for the help but it didn’t work. I think that I’ll need to make two scripts for each door but with some type of coding that it won’t work until the other character touches it’s door.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class endtrigger : MonoBehaviour
{
[SerializeField] private string newlevel;
void OnTriggerEnter2D(Collider2D other)
{
if (other.CompareTag("Player"))
{
SceneManager.LoadScene(newlevel);
}
}
}