• 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 SpaceSloth · Dec 08, 2012 at 04:09 AM · cooldownboost

Afterburner Overheating

Hey guys! I need help with an afterburner overheating script for a game.

The player controls a spaceship, and with shift, he has the ability to use a 1.5 second boost, after what it will take 3 seconds to cooldown.

Now I want it to act like a real heating machine gun / engine, as in you can use it for 1 second, let it cool a bit, and use it again. But if you go over the 1.5 second threshold, it will need to cool down. If possible, I'd also like to display the percentage of heating.

I realise this might be very complicated, soI'm kind of clueless on how to proceed, could anyone help?

In C# if possible, thanks in advance!

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Owen-Reynolds · Dec 08, 2012 at 04:12 PM

Make a variable like `float thrustSecondsLeft=1.5f;`

Whenever you're thrusting, subtract `Time.deltaTime` from it. Otherwise add, up your max thrust seconds.

Logically, you can thrust when it's greater than 0, but that would allow players to hold down all the time for a jerky 1/2-thrust (build up 1 frame worth of time, use it, ... .) So maybe say you can only begin a thrust when 0.5 or more. Or, if they hit 0 they have "damaged it" and it drops to -0.5.

If you want to be really cute, you can play with the MAX. Let them build up a big one: at full thrustSconds, you could slowly build up to 2.5 seconds left. Or make it wear out with frequent use: Using thrust gives a tiny decrease to the max, which quickly "heals" back to 1.5 when at max.

For showing amount left, look around here for how to do a life bar.

Comment
Add comment · Show 3 · 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 SpaceSloth · Dec 08, 2012 at 04:49 PM 0
Share

Thank you for your answer! I will try that out now.

avatar image SpaceSloth · Dec 08, 2012 at 05:13 PM 0
Share

I tried putting two conditions, the first being if thrustSecondsLeft > 0, the turbo applies, if thrustSecondsLeft < 0, the turbo stops

The turbo runs fine up until the 1.5 seconds, then it stops, without regenerating, so I can't use it again. Any idea on how I can set a cooldown, so that the turbo can be used after 3 seconds?

Also I'll try to reset the thrustSecondsLeft slowly down on keyup, so that it reacts like a heated engine.

avatar image Owen-Reynolds · Dec 08, 2012 at 08:35 PM 0
Share

Are you regenerating it? Somewhere in update there would be a line "if not using turbo, increase the amount, up to 1.5 max?"

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

10 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

Related Questions

Add a Charger/Cooldown system to a movement script for a 2D Top-Down Shooter. 1 Answer

Cooldown Function Problem 1 Answer

Adding cooldown C# 1 Answer

Very Very Precise Timer ? 0 Answers

Power Up speed and jump boost 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges