Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by Derik-Stavast · Feb 13, 2017 at 12:12 PM · animationclick to move

How to increase an object's animation speed based on the speed of what the player clicks/taps onscreen

Hey guys!

I'm extremely new to Unity and was wondering if anyone could share their knowledge as to how I would go about increasing/decreasing an objects animation speed and it's actual movement speed based on the speed that the player clicks/tap on screen? If no clicking/tapping is detected the object would move on a set default speed.

Example would be: if no clicks/taps are detected player movement speed would be 1 m/s. 3 clicks/taps a second would increase the speed by lets say 2 m/s, while clicking/tapping 5 times a second would increase the speed to 4 m/s and so on.

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 OmerDoron · Feb 13, 2017 at 02:06 PM

note that this script will change the overall time scale in your whole project, but I think that will help you

 using System.Collections;
     using System.Collections.Generic;
     using UnityEngine;
     
     public class HeadHit : MonoBehaviour {
     
         public float speedIncreaseAmount = 0.1f; //you can change that in the inspector.
     
         void Update () {
             if (Input.GetButtonDown ("Fire1")) {
                 Time.timeScale += speedIncreaseAmount; //if player tapped, increase overall timeScale by speedIncreaseAmont.
         }
     }

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 Derik-Stavast · Feb 13, 2017 at 03:25 PM 0
Share

Although this works and it's fun to look at the object still needs to decrease speed again if there are no clicks happening and/or if the player clicks very slowly (less than 3 clicks a second).

Think of it as a character walking. If I continuous click at a rate of 3 clicks a second the player character will then Jog and if i stop clicking the player will go back to his/her walking state. If I click more then 3 clicks a second the player will go into a fast running state and if no clicks are detected, the character will slow down into his/her walking state go back and so on.

thanks for the fast response though.

avatar image afshin_a_1 Derik-Stavast · Jul 12, 2017 at 02:13 PM 0
Share

@Derik-Stavast this is my question too. please let us know if you had any Success in this case.

avatar image afshin_a_1 · Jul 12, 2017 at 02:12 PM 0
Share

this isn't a good answer because changing the timescale will change the overall time scale in whole project. he's looking for a way to increase the speed of player animation and player obj itself, just like in real world when we decide to run but things and creatures around us stay like the way they were!

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Can I make animations snap to a frame? 1 Answer

click to move player and animations. 0 Answers

How to select an animation clip by index number? 7 Answers

How do i make my chracter stop moving when the destination has been reached?,How do i prevent my character from moving when reached the destination 0 Answers

How to make animations work in a click to move system (Unity 2D) 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