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 PuzzleBox · Oct 11, 2011 at 07:37 PM · arraytimespawnissue

Unity Engine issue...

I made myself several scripts, one controls a timer, another is an spawn controller that uses an array. My problem is that yesterday all of my scripts were working fine but when I logged on today the timer won't count down and the spawn controller won't spawn clones anymore. What could be the issue?

edit

 private var startTime;
 private var restSeconds : int;
 private var roundedRestSeconds : int;
 private var displaySeconds : int;
 private var displayMinutes : int;
 var Clock : GUIText;
 var newSkin : GUISkin;
 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);
     
     //display messages or whatever here -->do stuff based on your timer
     if (restSeconds == 10) {
     }
     if (restSeconds == 0) {
         Time.timeScale = 0.0;
         GUI.Box(Rect(20, 15, 1040, 580), "");
 
         if(GUI.Button(Rect(60, 300, 450, 200), "Quit")) {
             Application.Quit();
         }
         if(GUI.Button(Rect(560, 300, 450, 200), "Replay Level")) {
             Application.LoadLevel("Level_1");
         }
     }
     //display the timer
     roundedRestSeconds = Mathf.CeilToInt(restSeconds);
     displaySeconds = roundedRestSeconds % 60;
     displayMinutes = roundedRestSeconds / 60; 
     
     Clock.text = String.Format ("{0:00}:{1:00}", displayMinutes, displaySeconds); 
 }
 
 //Total Score Script
 
 var ScoreBoard: GUIText;
 static var Points = 0;
 private var Total: int = 0;
 var topscore : int;
 
 function Update ()
 {
     ScoreBoard.text = ("Score: ") + Points;
     if (Points >= topscore){
         Application.LoadLevel("Level_2");
         Points = 0;
     }
 }

and here it the spawn script:

 var arr : Array;
 var game_cube : Rigidbody;
 var cube_count = 0;
 var walker0 : Transform;
 var walker1 : Transform;
 var walker2 : Transform;
 var walker3 : Transform;
 
 function Start ()
 {
     InvokeRepeating("LaunchProjectile", 2, 1);
     arr = new Array();
     arr.Push(walker0);
     arr.Push(walker1);
     arr.Push(walker2);
     arr.Push(walker3);
 }
 
 function LaunchProjectile ()
 {
     var randomPick : int = Random.Range(0,3);
     var spoint : Transform = arr[randomPick];
     var instance = Instantiate(game_cube, spoint.position, spoint.rotation);
     instance.velocity = Vector3.zero;
     cube_count++;
 }
Comment
Add comment · Show 2
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 DaveA · Oct 11, 2011 at 07:57 PM 0
Share

You would need to post the code

avatar image PuzzleBox · Oct 11, 2011 at 08:29 PM 0
Share

the most confusing thing is that I have gravity check box turned on and the object with the AI clones don't fall.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Dudesaydude · Oct 12, 2011 at 08:33 AM

This might not be useful but maybe you can check in inspector panel if you´ve set you´re variables? Sorry if this doesn´t help. I´m nowhere near professional but I would love to help someone with the little knowledge I have. God I hope this is of some use to you.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

random spawn locations.... 2 Answers

Instantiate 1 at a time at each transform in array 1 Answer

Multiple spawn points using Array... 1 Answer

Random textures... 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