Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Persona · Dec 17, 2010 at 02:41 PM · scene-loadingrpgtransition

RPG Battle Transition

Can anyone tell me how to swap scenes like in an RPG when a battle take place, and reload the previous screen in the same location?

Basically, how do I reload a previous level in the same position as before after swapping to the battle scene?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Statement · Dec 17, 2010 at 04:59 PM

You need to keep track of the game state and restore the game objects when returning to the previous scene (referring to scene as level). This can become complicated depending the scope of your game. As far as I know, Unity has no way to automatically store the state of a level so it becomes easily reloaded at a later point in time.

You'll have to either

  • Use third party libraries that deal with this problem and use them. Search for it. I don't know any.
  • Write custom code that allow you to restore the state before you went into battle.
  • Find another approach to your battle system.


Another approach would be to have a different place within your scene where battle takes place. Briefly disable the characters in the "main world" while you're in the battle. This might be easier for you to implement. In the end you'll have to make the decision which would fit your game best.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Persona · Dec 24, 2010 at 01:51 AM 0
Share

Any Idea on how to write the custom code?

avatar image Statement · Dec 24, 2010 at 02:11 AM 0
Share

Yes, but it is quite complicated. You have to consider so many different states. It's not only a question about restoring positions, rotations, forces, materials, textures, colors (or what have you) but you also need to restore destroyed items, remove created items. The list grows large. I think a simple solution would be to have your battle take place inside the same scene/level. You could create the "battle" using prefabs if you need to. It would probably be easier than to load different levels and restore state.

avatar image Statement · Dec 24, 2010 at 02:14 AM 0
Share

You could use several approaches. You could use "reflection". You could use "memento pattern". These in itself are complex enough not to be covered in my answer - use google and find a wealth of information about them. I wrote such a system for Bob Came in Pieces where we needed to store data for each checkpoint. The result wasn't pretty and it was hard work getting it right. Basically every member variable had to be tracked and co-routines were out of question since they held a state I couldn't re/store.

avatar image Persona · Mar 24, 2011 at 04:48 AM 0
Share

I think I finally worked something out by string the location before the jump.

avatar image
0

Answer by Dominicbg · Apr 04, 2015 at 08:48 PM

My solution was to make 2 scene, one for the map and the other for the battle. At the loading of the game we spawn both. Each one have one have their own camera.

I did a Battle Manager, when I do the collision I call this and SetRender(true) the battle/camera and vice-versa.

I also did a SetPreference (with int since bool doenst really work) which save if I'm in battle or not. Now in all my overworld script there's a condition if the Battle is on or not, if yes, nothing work.

//To set my battle

InBatteBool = 1; PlayerPrefs.SetInt("InBatteBool", InBatteBool); PlayerPrefs.Save();

//To test if the battle is on

if (PlayerPrefs.GetInt
("InBatteBool") == 0){}

I don't know if its clear, it's my first time haha, don't hesitate if you have more question!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

Create loading bar then scene transition 1 Answer

Can you create transitions between levels using Application.LoadLevel? 6 Answers

Custom 'wipe' Transition between scenes 1 Answer

WWW object not working properly after runtime scene load 1 Answer

How to load a different scene at start of game? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges