Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 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 /
avatar image
0
Question by Mmocraft · Apr 07, 2021 at 08:10 AM · loadingstartdata storagestarting

Method in Start() not running, but in Update(), why?

Hey, im currently at building an automatic save and load system. On the Editor in Unity its all working well. But for some reason if i start the Game on my Phone, the loading of my inventory works, but the Player position does not. Even if i do the exact same thing with the data, and how i save and load it.

For test purposes i run the "LoadPlayer()" method in Update once, and like this it is working. It really confuses me that it is working like this:

 void FixedUpdate()
     {
         if(!loadedPos){
             LoadPlayer();
             loadedPos = true;
         }
     }

but not like this:

 void Start(){
         LoadPlayer();
         ...
 }

Does anyone have an idea what could cause that?

my inventory is loading in the second way btw.

Thanks for every help!

Comment
Add comment · Show 1
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 jackmw94 · Apr 07, 2021 at 08:31 AM 0
Share

I'd be very surprised if it was "not running", I think it's much more likely that it's running too early to function as you'd expect. What's happening in LoadPlayer and what effects are you seeing that make you think it's not running?

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by UnityM0nk3y · Apr 07, 2021 at 08:39 AM

To my understanding:

The reason why "FixedUpdate" worked, and not "Start" is because "FixedUpdate" are called for every "Physics Step". Meaning it happens after "Start".

The problem is probably with "LoadPlayer();", this method has to be run after another method, and "Start" is too early.

To test this theory try this:

     private void Awake()
     {
         StartCoroutine(loadPlayerDelayed());
     }
 
     IEnumerator loadPlayerDelayed()
     {
         yield return new WaitForSeconds(0.1f);
         LoadPlayer();
         Debug.Log("PlayerLoaded");
     }








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 Mmocraft · Apr 07, 2021 at 10:01 AM 0
Share

Ahh ye that sounds logical! with your method it worked out aswell! the Loadplayer method looks like this (just realized that might be an intresting information):

     public void LoadPlayer(){
         PlayerData data = SaveSystem.LoadPlayer();
 
         Vector3 position;
         position.x = data.position[0];
         position.y = data.position[1];
         position.z = data.position[2];
 
         transform.position = position;
     }
avatar image UnityM0nk3y Mmocraft · Apr 07, 2021 at 10:09 AM 1
Share

I had similar issues when I used to develop for Andriod. The problem is that the phone can only handle so much "processing" at the start of your game, so perhaps do use a "delayed Load" routine, and just close your loading screen afterwards?

avatar image
0

Answer by singhlaxman9761 · Apr 08, 2021 at 12:58 PM

If is there any exception occur in Awake() function then Start() function will not call. Make sure there is not any exception in Awake() function.:)

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 HellsHand · Apr 08, 2021 at 01:25 PM 0
Share

The original post isn't using Awake() at all. Please read the questions.

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

119 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Loadingscreen and play Level when initialized completely 1 Answer

New to programming what should I learn? 9 Answers

Loading similar items from JSON (How should I structure it?) 1 Answer

Scene starts before scene loading is finished 0 Answers

[CLOSED] Unexplainable fluctuations when setting a gameobject's transform.position 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