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
0
Question by richardzzzarnold · Jan 18, 2011 at 12:13 PM · loadlevelloadleveltimeout

timed out load level

Hi I want to have a timed out load level so that if nothing is happening, ie no button has been pressed for 15 seconds then the game automatically loads the next level, so that if the player is not paying attention, the game automatically goes through all the levels. I assume that i need a boolean function ( have any buttons been pressed ?) , but am not sure how to write that..

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 Noah-1 · Jan 18, 2011 at 07:22 PM

Hello, you can use a simple timer like this, you can set it to 15 seconds. Check it out.

private var startTime; private var restSeconds : int; private var roundedRestSeconds : int; private var displaySeconds : int; private var displayMinutes : int;

var countDownSeconds : int;

function Awake() { startTime = Time.time; }

function OnGUI () {

//make sure that your time is based on when this script was first called //instead of when your game started

var guiTime = Time.time; //startTime;

restSeconds = countDownSeconds - (guiTime);

//Here you can diplay messages or change the prints for applications.LoadLevel ("YOUR LEVEL")

if (restSeconds == 60) { print ("Time is running"); } if (restSeconds == 0) {

print ("Time is over")

 //do stuff here

}

//display the timer roundedRestSeconds = Mathf.CeilToInt(restSeconds); displaySeconds = roundedRestSeconds % 60; displayMinutes = roundedRestSeconds / 60;

text = String.Format ("{0:00}:{1:00}", displayMinutes, displaySeconds); GUI.Label (Rect (220, 25, 100, 30), text);

}

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 richardzzzarnold · Jan 23, 2011 at 03:22 PM 0
Share

Thanks but it isnt really what I was looking for. I was was looking for something that deter$$anonymous$$es that no activity has taken place, and then acts accordingly

avatar image
1
Best Answer

Answer by Bunny83 · Jan 27, 2011 at 06:07 PM

After i looked into your other questions i guess you prefer JS (or Unityscript). Just setup a simple "timer" and you have to reset it when the user do "something". The "something" could be Input.anyKey and / or Input.mousePosition and / or Input.touchCount > 0 and / or accelerationEventCount > 0 if you work on iPhone (i guess you do).

var Timeout : float = 15; var currentTimeout : float; var OldMousePos : Vector3;

function Start() { ResetTimeout(); }

function ResetTimeout() { currentTimeout = Time.time + Timeout; }

function Update() { if (Input.anyKey || (Input.accelerationEventCount > 0) || (Input.touchCount > 0) || (Input.mousePosition != OldMousePos)) { ResetTimeout(); } if (Time.time > currentTimeout){ ResetTimeout(); // TODO: Load your level here } OldMousePos = Input.mousePosition; }

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 richardzzzarnold · Jan 28, 2011 at 12:53 PM 0
Share

thanks so much Bunny ! it works perfect now ( i just had to make some adjustments now of course )

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

No one has followed this question yet.

Related Questions

Wait n-seconds before loading level 1 Answer

FPSPlayer script from FPS tutorial won't work... 0 Answers

How Do I Exit Level? 1 Answer

scene loader issue 0 Answers

Saving a variable through loads 1 Answer


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