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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by iHunterKiller · Mar 04, 2014 at 09:37 PM · spawnarraysenumwave

JS: Dump array value in an Enum

Hey guys. Im trying to make a spawning system for our game. We want it to work entirely through the inspector.

We start off setting the GameObjects to spawn, then set the amount of waves and amount of pushes within each wave. Finally we set which game objects spawn and how many of them.

(im really sorry this code isnt linked correctly, that 101 010 button isn't doing anything for me)

 var enemies : GameObject[];
 var amountOfWaves : WaveAmount[];
 
 class WaveAmount  
     {
         var wavePushes : WavePushes[];
     }
 
 class WavePushes
     {
         var startTimeSinceLastPush : float;
         var enemyBuild : Composition[];
         
     }
 class Composition
     {
         var Spawn1 : EnemyList;
         var spawn1Count : int;
         
         var Spawn2 : EnemyList;
         var spawn2Count : int;
         
         var Spawn3 : EnemyList;
         var spawn3Count : int;
     }

 enum EnemyList
     {
         enemies[0],
         enemies[1],
         enemies[2]
     }


The problem is that it doesnt work at all. Perhaps im going about this situation all wrong, but i haven't been doing this for very long and im kind of lost.

Trying to link the array to the enum and them back into the class isnt working ... if its possible at all.

If it changes anything, we hope to use those enum values inside the Update function to instantiate them based on the spawnXCount.

Comment
Add comment · Show 4
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 iHunterKiller · Mar 04, 2014 at 09:52 PM 0
Share

i edited the code a little bit to remove all the needless duplicates (was a much longer enum list, etc)

avatar image Jamora · Mar 04, 2014 at 10:02 PM 0
Share

Enums are compile-time constructs for na$$anonymous$$g things. This means, they must have a value at compile-time and thus expressions are not suitable, as they might evaluate to different values during run-time.

In C#, enums are basically named ints.

avatar image iHunterKiller · Mar 04, 2014 at 10:10 PM 1
Share

Ah i see, thank you Jamora.

So ive changed it a little bit and its working as planned now.

 // top
 var enemies1 : GameObject;
 var enemies2 : GameObject;
 var enemies3 : GameObject;

 
 //bottom
 enum EnemyList
     {
         enemies1,
         enemies2,
         enemies3
     }

and it looks great in the inspector too. tyvm Jamora

avatar image Jamora · Mar 04, 2014 at 10:14 PM 1
Share

No problem. You should either convert your comment to an answer or post your solution as an answer, and then mark it as correct.

1 Reply

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

Answer by iHunterKiller · Mar 04, 2014 at 10:16 PM

The error was in trying to use an array. Jamora helped me solve it :)

Change the top and bottom of the original code to the below. Now i have to sort out the spawning ^^ Perhaps a coroutine

 // top
 var enemies1 : GameObject;
 var enemies2 : GameObject;
 var enemies3 : GameObject;
  
  
 //bottom
 enum EnemyList
 {
 enemies1,
 enemies2,
 enemies3
 }
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

21 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 avatar image avatar image avatar image avatar image

Related Questions

Zombie Wave Spawning script 1 Answer

Spawn "n" Enemies Every "nth" Wave? 1 Answer

How to prevent infinite loop when Array Index Is Out Of Range 2 Answers

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

Can I call a function on a behavior attached to a prefab from it's spawner object? 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