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 Halo500 · Oct 19, 2013 at 05:36 AM · mobilerunningfootsteps

Convert "SHIFT" button for running to Mobile?

I have this script (courtesy of Alucardj) and it is a script for running and playing the footstep sounds. Now since I am trying to apply this script (which is for PC) into my Android game, how will I be able to convert the "hold the shift button to run" mechanic, into "hold the right touch pad to run"?

Here is the portion of the script:

 function SetSpeed()
 {
     var speed = walkSpeed;
      
     if ( chCtrl.isGrounded && Input.GetKey("left shift") || Input.GetKey("right shift") )
     {
         speed = runSpeed;
     }
      
     chMotor.movement.maxForwardSpeed = speed;
 }
  
 function PlayFootsteps()
 {
     if ( Input.GetAxis( "Horizontal" ) || Input.GetAxis( "Vertical" ) )
     {
         if ( Input.GetKey( "left shift" ) || Input.GetKey( "right shift" ) )
         {
             // Running
             isWalking = false;
             isRunning = true;
         }
         else
         {
             // Walking
             isWalking = true;
             isRunning = false;
         }
     }
     else
     {
         // Stopped
         isWalking = false;
         isRunning = false;
     }
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 yogee · Oct 19, 2013 at 06:04 AM

http://docs.unity3d.com/Documentation/ScriptReference/TouchPhase.Stationary.html

this link ll help u

Comment
Add comment · Show 4 · 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 Halo500 · Oct 19, 2013 at 06:41 AM 0
Share

Alright, this has activated the running (finally!) which is great. Thank you for the link.

The only problem now is that the character is now always running, because my finger is of course stationary when I am leaving my finger on the screen for the direction of the character movement. How would I approach this issue? :)

avatar image yogee · Oct 19, 2013 at 06:46 AM 0
Share

little bit clear

avatar image Halo500 · Oct 19, 2013 at 06:52 AM 0
Share

I need my finger to be on the touch screen in order to make the character move, and for which direction my character will walk with where my finger is at. Since my finger will always need to on the screen, touchphase.stationary will always be applied to the game, do I will always be running.

I'm thinking if a possible way to solve this would be to have a separate GUIButton on the screen used just for running. Basically a running button with a little stick figure in a running stance in it. :)

avatar image yogee · Oct 19, 2013 at 07:27 AM 0
Share

if(TouchPhase.Began ) { //walk // u can move ur finger while moving it won't affect the movement //until u release ur finger (TouchPhase.Ended) } else if(TouchPhase.Ended) { //end of walk //i.e, release of ur finger }

touch.jpg (34.2 kB)

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

Footsteps Script for Running and Walking 3 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Conversion of a static class to struct? 1 Answer

How to only get touch on specific object? 0 Answers

cant touch multiple objects on screen (c# , mobile) 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