- Home /
New Stage?
As some may know, I am making a paper mario game. If you have played/seen enough of it, you would know that when you touch an enemy, a battle scene opens up. The problem is that I don't know how to get my characters from where they are at in that point to a different stage. Or as some call it; "RPG style".
Long story short: I want a separate battle platform to show up if I touch an enemy, like in RPG's.
I don't have any coding to show, because I don't even know how to BEGIN on doing this. Does anyone know how to make this happen?
Only problem, I only want to use enemies from that area, and If I load a new scene, It wont know what enemies to use or how many.
There's plenty of info to research about passing information between scenes. Don't let that stop you if that is your preferred approach.
Answer by AlwaysSunny · Jul 21, 2015 at 05:49 PM
It may be "easiest" to use a literal scene transition, but it's possible this would be more trouble than it's worth. It depends upon your preference, and several other factors we don't know about.
Here are your obvious options:
A fake scene transition
This wouldn't involve literally loading a new scene file, but instead either hiding nearly everything in the scene, or otherwise moving the focus (camera) such that the original environment is not in view. You'd then use an entity placement and referencing strategy that reflects the fact that this is a new and temporary location, and discard these elements + unhide or return focus to the overworld when it's time. Ideally, you would create a prefab for your special RPG battleground environment, so you've only got to drop in, use, and delete a single object. This prefab could know where to place entities, and could include its own UI canvas and camera (just pause the overworld, disable its camera, and use the battleground camera for the duration). Could be pretty darn slick.
A real scene transition
This involves loading a new scene file, and loading the original when the fight is over. This is a bit cleaner, except that it implies having to save and load any aspects of the overworld scene if you want it to remember what the player has done in that environment so far (unlocking doors, destroying crates, whatever). If your save system is built around this idea, it should be quite simple, and is probably the superior approach if you're going to implement any kind of save system for saving the user's progress throughout the overworld scene(s).
Answer by brunopava · Jul 21, 2015 at 06:04 PM
On my opnion you should begin with this aproach: (if you don't want to change scenes)
Create an "arena" (where your characters will fight) Position a camera to see this arena how you want.
Now the tricky part. You need to set the arena layer and the culling mask of the camera in order that te camera will only render the arena.
Position this arena and the camera far away from your game. Now, when you characters collide in-game. You instantiate new prefabs in the arena (the guys who will fight). Disable your main camera and activate the arena camera.
Or, if you want to change scenes.
There is a lot of ways to pass information between scenes. One of them is a Singleton. Other is DonDestroyOnLoad();
I think I'll use the change scenes method. $$anonymous$$y question is: how do you use singleton? Could you put it in a script if it's not too confusing?
Take a look at the "Persistent Singleton" method example here: http://unitypatterns.com/singletons/