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 Eraclion · Mar 31, 2014 at 04:56 AM · androidcharactercontrollergui-buttonrun

How i can make a running button?

I've been trying to create a button that increases the player's speed depending on the speed with which this button is pressed.

but I can not get the result I need. Speed does not decrease correctly if I press the button more slowly, and achievement not make it more difficult to increase as the value becomes higher

here part of the code:

 public var forwardSpeed : float = 2;
 
 public function Velocity()
    {
      if ("morevelocity"){      //If the button is pressed
          if(forwardSpeed<25){
         forwardSpeed += 1 / forwardSpeed;
         }
        
                
     }
 }
 function Update()
 {
 
 if (forwardSpeed>1.5){
 forwardSpeed -= 0.5 * Time.deltaTime * forwardSpeed;
 }
 
    
     var movement = Vector3.right *  forwardSpeed * 1;



i need some help, i try some much.

Comment
Add comment · Show 12
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 Noob_Vulcan · Mar 31, 2014 at 05:08 AM 0
Share

Your UpperLimit =25 ,lowerLimit=1.5 and default=2f; Your update condition will be always true . When ever you will press the speedup btn ur decreasespeed will be also called.

avatar image Eraclion · Mar 31, 2014 at 05:12 AM 0
Share

in fact, I need the player to press the button as quickly as possible or else the speed will decrease.

avatar image Noob_Vulcan · Mar 31, 2014 at 05:29 AM 0
Share

plzz give some data..i cant understand " Speed does not decrease correctly" . so that i can help. By how much amount it decrease...stuff like tat

avatar image Eraclion · Mar 31, 2014 at 05:34 AM 0
Share

I appreciate that you try to solve my problem, and I apologize if I can not express myself properly. $$anonymous$$y problem is that when you reach 25 speed, this does not require you to press quickly, but slowly press speed is maintained or even increases, so does not require the player to press quickly.

avatar image Noob_Vulcan · Mar 31, 2014 at 06:18 AM 0
Share

float fv=2f; Transform _transform; // Use this for initialization void Start () { _transform = this.transform;

 }
 
 // Update is called once per frame
 void Update () {
     if (fv > 1.5f) {
          fv -= 0.5f * Time.deltaTime * fv;
                     _transform.position = new Vector3 (fv,_transform.position.y,_transform.position.z);
             }

     if (Input.Get$$anonymous$$ouseButtonDown (0)) {
         if(fv<25)
             fv += 2f;    
     }
 }
Show more comments

0 Replies

· Add your reply
  • Sort: 

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

22 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

Related Questions

How would I add android support to this character controller? 1 Answer

gameobject.GetComponent().target is not working 1 Answer

Changing input to Character Controller from keys to touch screen 0 Answers

Touches aren't working on Android 1 Answer

WHY WON'T MY GAME LOAD ON MY DEVICE? 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