Hey, I’m currently working on a game, that uses a global map for movement through the world. It is a top-down view and I want players to be able to enter houses, by walking into them. I want to implement a mechanic similar to Pokémon, where you get teleported or loaded into another scene when you enter a cave or a house. Is there a “smart” way of doing that? One solution I can think of is creating a game object placed in the right spots by hand and then adding a script to it. But that does not sound like an intended solution for something that should be so simple? Are there any features that I could use to implement something like that?
What on earth could be simpler than a script on a GameObject?! This is how everything outside of the core engine functionality works in Unity. That’s how I would do it. That’s how 100% of the 50 to 60 other Unity engineers at my company would do it.
Hello.
I am currently engaged on a project where I have the same kind of requirements. The world is made up of 2D Tiles and the player sprite moves around confined to the same grid. When the player walks onto a tile that is the ‘door’ to another scene, the scene changes and they are standing on the other side of the door.
I use a Collider2D set to trigger for this, that detects when the player’s Rigidbody2D enters it, and sends the player to the appropriate scene. This is a GameObject with a script on it, and like Kurt said is pretty much as simple as you can get.
There are also plenty of objects in the game that the player can walk upto and interact with, be it a signpost, a closed door, an NPC. These objects all inherit from an ‘Interactable’ class that I have written and are also a GameObject with a Collider2D on it.
If this doesn’t sound plausible for your project, could you please elaborate on why and what restrictions you’re trying to work around?