Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
This question was closed Oct 30, 2013 at 08:53 PM by WhipJr for the following reason:

commands.close.hint.6

avatar image
0
Question by WhipJr · Aug 18, 2011 at 02:12 AM · transformplayervector3spawn

how to make a character resume after going into a random battle?

i got my random battle generator working, now all i need is a way to save my character's position on one map so i can load a battle and fight, then after the battle resume exactly where he left off. like Final Fantasy VII's random encounters... i already know that it will have to do with vector3 and the character's transform data. but im not sure how i could keep track of that then use that information to respawn the character in that position.

answers that could help:

  1. how to temporarily store vector3 data then re-use that info to spawn the character after the battle is over.

...thats about all i can think of that would really help actually...

if you can think of anything else that you think might help. please elaborate :)

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

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by Julien-Lynge · Aug 18, 2011 at 04:05 AM

I take your question to be 'how can I store data when loading a separate scene, then load the original scene again and access that data'. If that's not quite it, leave me a comment below.

To keep information between scenes, your easiest bet is probably to build some kind of 'backend' or 'scene controller' (call it what you will) that is generated once when you start up the game and follows the player around as they go to different scenes, keeping track of state information like their experience and what quests they have completed. You'll definitely need the dontDestroyOnLoad functionality. Pop your script in a gameObject in your Main Menu or Loading screen and fill it with info when the player selects 'Load' or 'Play'.

Further, I'd suggest making as many variables and functions static as possible, so you can call them without having to have a reference to a specific game object containing the script (using Find or whatnot). With static variables, you can access them with MyScriptName.varName (where MyScriptName corresponds to the C# class or the JS file name).

With that, your question becomes trivial: just before loading the other scene, load up your Vector3 myPositionBeforeFight (or whatever). Then, in an OnLevelWasLoaded call, restore the player to that position.

Comment
Add comment · Show 2 · 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 WhipJr · Aug 18, 2011 at 08:41 PM 0
Share

thank you or this reply, im not sure if its gonna help quite yet but it looks like its gonna help out a lot. im about to try and use some of this information in about 2 seconds and see how it works out. ill let yu know any problems.

avatar image Julien-Lynge · Aug 19, 2011 at 04:30 AM 0
Share

Sure thing. If it works for you mark it as accepted so it gets taken off the unanswered list.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

charachters stand next to each other 0 Answers

C# 2d Spawn Randomly along Camera Borders 1 Answer

How the player can translate 1 "unit" and not smouthly. 2 Answers

How to determine speed of an object when using transform.position 2 Answers

How do I create an Initial Spawn Point? 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