Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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
0
Question by Fallen117 · Jul 27, 2015 at 09:05 AM · scenerotatescene-loading

Objects stop rotating when I go a scene, and then back to the original

Okay! This is kind of long but I will try to be concise:

Scene 0 has this script on a cube to make it randomly rotate:

function Start ()

 {
 
  var v3 = Vector3(Random.Range(-50.0, 50.0), Random.Range(-50.0, 50.0), Random.Range(-50, 50));
  GetComponent.<Rigidbody>().AddTorque(v3 * 2);
  
 }

Then in Scene 1 this script brings me back to Scene 0:

  #pragma strict
  
  function LoadScene ()
  {
      Application.LoadLevel("scene0");
  }

So if the LoadLevel Script is in Scene 1, it brings me back to Scene 0 and the cube is at its default position, NOT rotating.

However, if I put the the LoadScene in Scene 0, run it, it will keep rotating with a new random rotation.

I have tried switching the rotation to a Function Update, FixedUpdate none worked.

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

· Add your reply
  • Sort: 
avatar image
1

Answer by Rhylvin2015 · Jul 27, 2015 at 10:22 AM

That's because you're just going to another scene and nothing was save. basically what I'm saying is you did something on scene 0, didn't save anything went to scene 1 who wants to go back to scene 0 and since nothing was saved it wounded up to a default. Try using PlayerPrefs. http://docs.unity3d.com/ScriptReference/PlayerPrefs.html

Its a very awesome feature of Unity Scripts that lets you save an Int, Float and a String

I don't know if this will work but the idea is there, in your Scene0 save your v3 with this

     PlayerPrefs.SetFloat("v3",v3);
 //I don't know either if the v3 returns a String or a Float or an Int. just change if its not Float.


this should be the correct term to get that random rotation

 GetComponent.<Rigidbody>().AddTorque(PlayerPrefs.GetFloat("v3") * 2);

Comment
Add comment · Show 1 · 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 Fallen117 · Jul 27, 2015 at 01:22 PM 0
Share

Edit time!

So I tried this and nothing :(

But someone actually came up with the idea of time.timescale being set to 0 in order to pause... and that was it.

$$anonymous$$y menu scene wasnt going back to time.timescale = 1

So I changed it so that it does... and now it is working!

If you change you answer so that it incorporates time.timescale i'll hit the check mark!

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Load and run scene in background 1 Answer

Can I know if the current scene has been loaded from bundle? 0 Answers

Using UI.Button to Load Another Scene? (using outdated tutorial video) 1 Answer

Load new Scene with LoadSceneMode.Additive - I cannot interact with the new Scene, although it was set as Active Scene 0 Answers

Only one scene? 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