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 bebob235 · Dec 08, 2013 at 08:31 PM · instantiatespawntimer countdownspawnpointsrandomspawning

I'm having problems with my code

I created 4 empty objects around the board one on each corner. Each corner has a tag and name "yoWassup1"- up to "yoWassup4". I want a timer to count up until it gets to 5 and then picks a random number and spawns at the corresponding spawn point. The idea is for it to go in a loop and every 5 seconds the game gets harder and new ball is spawned in.

The error that comes up is that "The associated script can not be loaded. Please fix any compile errors." no errors show up on the console. It just doesn't go into play mode.

thanks a lot

my code is as follows:

 var thePrefab : GameObject;
 
 public var myTimer : float = 0.0;
 
 var spawning : boolean = false;
 
 var yoWassup1 : Transform;
 
 var yoWassup2 : Transform;
 
 var yoWassup3 : Transform;
 
 var yoWassup4 : Transform;
 
 
 function Update () {
 
  if(!spawning){
 
   myTimer += Time.deltaTime;
 
  }
 
  if(myTimer >= 5)
 {
 
  Spawn()
  }
  }
 function Spawn(){
 
 spawning = true;
 
 myTimer=0;
 
 var randNumber: int =(Random.Range(1,5));
 
 var location :Transform;
 
      if (randNumber == 1){
 
          location = yowassup1;
 
           Debug.Log ("PICKED 1");
 
          }
 
        else if (randNumber == 2){
 
           location = yowassup2;
 
           Debug.Log ("PICKED 2");
 
      }
 
       else if (randNumber == 3){
 
           location = yowassup3;
 
           Debug.Log ("PICKED 3");
 
      }
 
      else if (randNumber == 4){
 
 
          location = yowassup4;
 
           Debug.Log ("PICKED 4");
 
     }
 
 
 Instantiate(thePrefab, location.position, location.rotation);
 
  spawning = false;
 
     }


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 meat5000 ♦ · Dec 08, 2013 at 08:36 PM 0
Share

Have you linked gameobjects in the editor to deter$$anonymous$$e the spawn points?

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by robertbu · Dec 08, 2013 at 08:35 PM

Any chance you have error reporting turned off in the Console window. The stop sign with the '!' needs to be selected in the upper right corner of the Console window. I find five errors in this script. Your are missing ';' at the end of line 27, and the variable names you use don't match your declaration:

'yowasup1' is not the same as 'yoWassup1'. Case must match.

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 bebob235 · Dec 08, 2013 at 08:39 PM 0
Share

thanks! I don't know how I missed that

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

17 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

Related Questions

How do I control where enemies spawn? 1 Answer

Prevent object from spawning at a spawn point twice in a row? 3 Answers

Network.Instantiate players at each spawnpoint? Don't use the same spawnpoint? 1 Answer

Storing the Position Generated by Random.Range 2 Answers

one scene multiple spawn points 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