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 Deathspank · Oct 05, 2013 at 02:20 PM · randomspawnsystemarraylistpower-up

C# Power-up spawn system (selecting and releasing), need help scripting

Hello guys, I'm a beginner unity user and want to script a power-up spawn system for the power-ups I made.

The power-ups are inside a canister, that when the player triggers (by colliding to it) it will instantiate another object which have a power-up effect script - such as deleting enemies that hits it)

Anyway I want a way to spawn the powers in my game; so here my idea on how it will behave.

  • An ONGUI screen will come out with buttons that represent a power-up - SIMILAR TO THISalt text

  • If the player presses the button, it will enable the power-up to spawn in our spawner script

  • NEED HELP WITH The spawner script always have to check if the game has 4 power-ups, if not, in 5 seconds it will spawn a new RANDOM power-up from a list of power-ups that was unlocked (player enables them by clicking the button from the ONGUI)

  • The power-ups will shoot random (360) from a point (empty game object)

  • Then I will add a force to it, so it shoots out

I have the basic Idea on how to do this, but I don't have the experience and knowledge to write the code by myself.

  • Basically we need to put my power-ups in an array of empty gameobjects, I have at least 13 power-ups that the game can spawn.

  • Then it has to check if that power-up is activated by a bool i guess,

  • If it is activated (unlocked by player), then the spawner will random select 4 of those unlocked power-up to spawn in the game... we could probably do this by having a script that checks if the power-up is unlocked and then have it add to another array of only unlocked power-ups,

  • Then out of those new array of unlocked power-ups, the game will spawn only 4 random power-ups, each time that the game has less than 4, it will wait 5 seconds before spawning a new one.

I think I have the basic Idea just need help with the layout of the script, if you have even a tutorial on how to do it then awesome :)

Please help me guys

Comment
Add comment · Show 7
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 Deathspank · Oct 05, 2013 at 09:43 PM 0
Share

Please guys :(

avatar image Myth · Oct 05, 2013 at 10:02 PM 0
Share

C#, Boo or javascript?

avatar image Deathspank · Oct 05, 2013 at 10:05 PM 0
Share

Oh yeah I forgot to mention, I only know mostly C#.

Cheers man.

avatar image Deathspank · Oct 06, 2013 at 01:19 AM 0
Share

Anyone? Please/

avatar image Deathspank · Oct 06, 2013 at 06:34 AM 0
Share

Bump! Anyone can help me?

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Myth · Oct 05, 2013 at 10:16 PM

use

 Array.RemoveAt()
 Array.Add()
 and 
 Array.length

to manage the array of power-ups.

you can have the script that detects collision find the spawn object and call a method to remove it from the array.

Comment
Add comment · Show 2 · 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 Deathspank · Oct 05, 2013 at 10:59 PM 0
Share

Too little for me to go on :( I'll have problem getting the script to work as it'll be hard for me to structure this script properly... But I'll go watch a tutorial on how to use arrays...

avatar image vexe · Oct 06, 2013 at 09:13 AM 0
Share

I'd watch all the beginner series from Unity, especially the scripting ones, good luck :)

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

18 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

Related Questions

Spawn object from Random Vector3 in array 0 Answers

Endless/infinite runner random enemy spawning multi lane 1 Answer

My loop keeps producing the same wrong result :,,( 2 Answers

How to randomly replace the main platform with additional ones? 0 Answers

Drop item from airplane 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