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 Dijit · Mar 30, 2014 at 04:17 AM · variabletimeincrement

How to make a variable fall/rise over time?

I'm somewhat new with scripting. I'm scripting a jump script and I'm trying to make it so that whenever the player is in the air a variable goes up, and that variable would negatively affect their jump height. So I wrote

 void Update ()
 { 
 if (isgrounded && (test>0) == true)  ;
    {int test =(test - 1);}

     if (isgrounded == false);
    {int test =(test + 1);} 

I realize that even if that worked it would increase/decrease the variable per-frame, rather that per-second, I was going to try to fix that later, maybe by making it a float

 if (isgrounded == false);
    {float test =(deltaTime*(test + 1));} 

any help you can give would be greatly appreciated

Comment
Add comment · Show 5
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 MousePods · Mar 30, 2014 at 04:27 AM 0
Share

Are you use a character controller or a rigidbody?

avatar image Dijit · Mar 30, 2014 at 06:34 AM 0
Share

I'm using a rigid body with a script that adds forces based on player inputs

avatar image robcbryant · Mar 30, 2014 at 07:49 AM 0
Share

Um...do you mean trying to create gravity?

avatar image Dijit · Mar 30, 2014 at 05:03 PM 0
Share

Not exactly, I was trying so after being in the air for a period of time the strength of the players jump would be reduced.

So if you mashed the jump key your jumps would become progressively less powerful.

Although, I do want to make gravity later, and the ability to increase/decrease variables over time would be good for that too.

is there a way to increase a variable by "x" per-second?

avatar image Lo0NuhtiK · Mar 30, 2014 at 05:09 PM 0
Share

is there a way to increase a variable by "x" per-second? --Dijit

@Dijit : Yes. If you search google or this board you'll find a ton of code showing how this is done.

1 Reply

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

Answer by guido123 · Apr 01, 2014 at 12:05 PM

to increase your amount per second it should be like this.

float test = (test + (Time.deltaTime * 1));

you could also try invokerepeating

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

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

Related Questions

Yielding for a changing amount of time? 2 Answers

Change GUI.Label text while it's active? 1 Answer

How do I make it so that it wont edit a variable again for a certain ammount of time? C# 3 Answers

how to make a varied countdown timer 1 Answer

GLSL: Get current time in millis 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