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 i2naok8 · Apr 28, 2013 at 06:37 PM · duplicateyield waitforsecondspower-up

Create a power up that last for a specific time

Hi! I making a videogame of shooting and when you hit a specific object you earn 10. The thing I need is create a power up that when you take it, the quantity that you earn duplicates for 10 seconds. I'm using yield waitforaseconds.

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 Loius · Apr 28, 2013 at 06:37 PM 0
Share

multiply by two while timer > 0

avatar image Jazzer008 · Apr 28, 2013 at 08:33 PM 0
Share

What's the actual question you want answering? If your using yield WaitForSeconds then just get a function to run when the player picks up the item, duplicate the pickup, do the yield for 10 seconds and change the pickup amount back.

If you want to do this more than once you'll have to create a timer that counts down every frame. Add an amount to the timer every time you pick up the power up, and when the timer is greater than zero, double the pickup amount. Then you just need to -= 1 from the timer each update if it's greater than 0.

1 Reply

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

Answer by DESTRUKTORR · Apr 28, 2013 at 09:07 PM

If this is the only multiplier you'll be using, simply add a boolean to the class that handles the scored-pickups (not the powerup), then, set the powerup such that when you pick it up, it sets that boolean to true, and calls Invoke("DeactivatePowerup", powerupTime); where powerupTime is the time (in seconds) that you want the powerup to last for, and make a void method (or function, if you're using javascript) in that same class, with the method signature void DeactivatePowerup() (or function DeactivatePowerup() : void, in javascript) in which you will set that boolean back to false.

If you are using other multipliers, multiply the incoming score by a float field stored in that monobehaviour, for the score multiplier, and simply add 2 to it (or multiply it by 2, depending on how you want it to affect it) and in the DeactivatePowerup() method, in stead of setting a boolean to false, you'll be doing the opposite operation you applied to the multiplier when the powerup was activated.

I apologize if this seems at all convoluted, but given no source to work with, I can't be of much more help than this.

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 Attrom · Apr 12, 2016 at 06:48 PM 0
Share

Thanks, I've been struggling with this all day.

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

16 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

Related Questions

Is there any difference if I duplicate a prefab in Hierarchy or drag it from Project tab? 1 Answer

Duplicating meshes without instantiating? 2 Answers

Unity3D - Ammo Texture repeat 2 Answers

How to start the animation of a duplicate object on a different frame 1 Answer

How do i get a GameObject in the Hierarchy view to duplicate from gameobject1 to gameobject2 0 Answers


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