MYCRAFTisbest Posted August 5, 2015 Share Posted August 5, 2015 Hello. This is probably a silly question, but I can't figure out how to make the game wait before doing the action I have coded it to do (load the last quicksave). I currently have this code segment: public override void OnActive() { UnityEngine.Debug.Log("[FK] Time Traveling"); Game _game = GamePersistence.LoadGame("quicksave", HighLogic.SaveFolder, true, true);//Wait 3 Seconds here _game.Start();}If someone could please help me out here and possible direct me to a good source to look off of that would be great. Thanks Link to comment Share on other sites More sharing options...
Crzyrndm Posted August 5, 2015 Share Posted August 5, 2015 public void OnActive(){ StartCoroutine(CoroutineExample());}public System.Collections.Generic.IEnumerable CoroutineExample(){ yield return new WaitForSeconds(3); game.Start();}Look up unity coroutines for more info Link to comment Share on other sites More sharing options...
MYCRAFTisbest Posted August 5, 2015 Author Share Posted August 5, 2015 public void OnActive(){ StartCoroutine(CoroutineExample());}public System.Collections.Generic.IEnumerable CoroutineExample(){ yield return new WaitForSeconds(3); game.Start();}Look up unity coroutines for more infoOK, I tried this and got a Null Referenceusing System;using System.Collections;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using UnityEngine;//Unnecessary Code Stuffs Removed for Convenience public override void OnActive() { Debug.Log("[FK] Time Traveling"); StartCoroutine(WaitThree()); } IEnumerator WaitThree() { yield return new WaitForSeconds(3); Game _game = GamePersistence.LoadGame("quicksave", HighLogic.SaveFolder, true, true); _game.Start(); } Link to comment Share on other sites More sharing options...
MYCRAFTisbest Posted August 5, 2015 Author Share Posted August 5, 2015 Right I figured it out. Having an issue regarding the explosion effect blowing the part up and ending the code early, but I can figure it out probably Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now