Unity. How to make a player interaction zone with objects (2d platformer)?

I'm new to Unity, please don't throw your sneakers. The game is based on Unity, a simple 2d platformer. I want to make a transition to another location in such a simple form (I'm going to use the script for other objects using the same mechanics): The player enters a certain zone (the desired sprite is located behind) and if he presses E in this zone, the transition to the next level/other action is performed. I've heard about triggers, but I absolutely can't think of how to implement such a construction. Please tell me, if not difficult, then in more detail.

 1
Author: Максим Моор, 2020-05-05

1 answers

You need to attach colliders to your player and the door itself (or whatever you have there). On the Collider doors to change the value of the IsTrigger to true, and write the script, which will be the method OnTriggerEnter2D, here is the link, where do you check the click of a button by using if(Input.GetKey(KeyCode.E)), here is the link you load a scene with Application.LoadLevel(), here is the link. I advise you to throw the script on the door itself.

 0
Author: Methorn, 2020-05-05 10:27:19