I'm new at Unity, so.. :) Im making 2D game, my character should enter the car by pressing F, Unity should load a new scene. There's my C# code:
void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Player")
{
//Debug.Log("TRIGGER");
if (carTitle == "98" && Input.GetKeyDown(KeyCode.F))
{
SceneManager.LoadScene("NewScene");
//Debug.Log("TRIGGER 98");
}
}
}
There's a problem. I used two Debug lines to see what exactly happens here. The first one is saying "TRIGGER" when my car is colliding with Player, it works fine. But the second one is keeping silent. Every car has a specific number public string carTitle, and IF my car is number 98 AND player hits the button F when car and player collide, it should load a new scene. Am I right? But nothing happens.