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 Ridgerunner · Nov 11, 2012 at 03:38 AM · timerjavaresetreload

How do I Reset Scene

I'm tring to Reset time after game is over and the counter goes to zero,I start the game in level select hitting the level 1 button it counts down fine to 000 but when I replay the Level 1 again the counter is still at 000 can some one help me Pleae????????

var aniFont1 : GameObject; // holds a sprite sheet - should be a number sheet 0-9 var aniFont2 : GameObject; // holds a sprite sheet - should be a number sheet 0-9 var aniFont3 : GameObject; // holds a sprite sheet - should be a number sheet 0-9

var playTime : float = 0.0; // playTime is the current time printed to screen - think of it like current game time var continueTimeDown : float = 0.0; // used to continue time down from stopped time var countDownDelay : float = 0.0; // used to delay time during counting var countDownAmount : float = 0; // amount to delay each time

var playTimeEnabled : boolean = true; // toggle for playTime var countDownEnabled : boolean = true; // toggle for countDown

function aniSprite ( spriteObject, columnSize, rowSize, colFrameStart, rowFrameStart, totalFrames, type:String) { var index : int = playTime; // to control frame location, playTime will equal the index count var font1 = ( index % 10 ); // font1 position var font2 = ( ( index - font1 ) / 10 ) % 10; // font2 position var font3 = ( ( index - font1 ) / 100 ) % 10; // font3 position

if ( type == "font1" ) index = font1; // check for which sprite sheet to use - font1 if ( type == "font2" ) index = font2; // check for which sprite sheet to use - font2 if ( type == "font3" ) index = font3; // check for which sprite sheet to use - font3 var size = Vector2 ( 1.0 / columnSize, 1.0 / rowSize ); // find scale to show on poly

var u = index % columnSize; // u cord separated from v, to find just the column and mod it var v = index / columnSize; // v finds location on row based on columnSize count var offset = Vector2 ( ( u + colFrameStart ) size.x, ( 1.0 - size.y ) - ( v + rowFrameStart ) size.y ); // offset uv's spriteObject.renderer.material.mainTextureOffset = offset; // apply the offset amount to the correct sprite sheet object spriteObject.renderer.material.mainTextureScale = size; // apply the scale amount to the correct sprite sheet object } function Update () { if (aniFont1 != null) aniSprite ( aniFont1, 10, 1, 0, 0, 10, "font1" ); // animated font sprite - type: font1 if (aniFont2 != null) aniSprite ( aniFont2, 10, 1, 0, 0, 10, "font2" ); // animated font sprite - type: font2 if (aniFont3 != null) aniSprite ( aniFont3, 10, 1, 0, 0, 10, "font3" ); // animated font sprite - type: font3

if ( playTimeEnabled && countDownEnabled ) // if countDown enabled, then use this for playTime { playTime = countDownDelay - Time.time + countDownAmount + continueTimeDown; // get playTime start } if ( playTime <= 0 ) // simple stop for countDown { playTimeEnabled = false; // stop timer - playTime countDownEnabled = false; // stop timer - countDown } }

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
0

Answer by AlexJBoyd · Nov 11, 2012 at 04:45 AM

It is really hard to read your code like that. However using Application.LoadLevel("Scene name your are loading") should work for ya.

Also, if for some reason some or your booleans or scores are not resetting properly then I suggest setting the variables you want back to their originals in an Awake() function.

Comment
Add comment · 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

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

10 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

Related Questions

Gun recoil and gun reload 2 Answers

Timer help please 1 Answer

Camerascript works strange! 0 Answers

Make player unable to shoot when reloading 3 Answers

oescape script name? 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