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 /
  • Help Room /
avatar image
1
Question by IKilledKenny_2 · Jan 12, 2016 at 12:39 AM · animationcollisionjoystick

GetAxis Is Too Fast!How can i make it slower?

Hello Unity3D.I have a problem with my GetAxis.The problem is I want my GetAxis to act as a button and when i move my joystick to left or right its really quick and it makes my character looks like it shuttering.I don't want that.What i want is for the character to move 1 pace or take one step depending if i move the joystick to the left or right.If anyone knows how i can do this.Can you please tell me how?

Heres what i got so far var Characters : GameObject[]; // Array of Weapons var selection : int = 0; var OkButtonP1 : String = "Accept_P1"; var OkButtonP2 : String = "Accept_P2"; var Player1Ready : boolean = false; var Player2Ready : boolean = false; var playerMovement : float = 0; var smooth : float =0; var speed : float =0; var amount : float =0; var gravity : float = 0; function Start () {

     for(var obj:GameObject in Characters)
         {
             obj.SetActive(false);
 
         
 
         Characters[selection].SetActive(true);
 
     
     }
     
 
 
 }
 
 function Update (){
 
 
   if (Input.GetAxis("Horizontal1"))
      {
          transform.localPosition.x += playerMovement * smooth * speed * gravity * Input.GetAxisRaw("Horizontal1");
      }
      
      if (Input.GetAxis("Depth1"))
      {
          transform.localPosition.z += playerMovement * Input.GetAxis("Depth1") * Time.deltaTime;
      }
 
 
 
   if(Input.GetKeyDown("a")||Input.GetAxisRaw("Horizontal2") == 1){
 
 
          {
         
             Characters[selection].SetActive (false);
             selection++;
 
             if (selection >= Characters.length)
                 selection = 0;
 
             Characters[selection].SetActive (true);
                 
             }
         }
 
 
 
         if(Input.GetKeyDown("d")||Input.GetAxisRaw("Horizontal2") == -1){
             Characters[selection].SetActive(false);
             selection--;
             
             if (selection < 0)
                 selection = Characters.length-1;
 
             Characters[selection].SetActive (true);
 
         }
 
         if (Input.GetButtonDown(OkButtonP1)&& Player1Ready == false) {
 
 
     
         Player1Ready = true;
 
         }
 
         if (Input.GetButtonDown(OkButtonP2)&& Player2Ready == false) {
     
         Player2Ready = true;
 
         }
 
 
 
 
 
 
         if (Input.GetButtonDown(OkButtonP1)&&(Player1Ready == true && Player2Ready == true))
 
         {
             PlayerPrefs.SetInt ("PreferedModel",selection);{
             PlayerPrefs.SetInt ("PreferedModel2",selection);{
             Application.LoadLevel("God N Angels Waterfall Shore");
          }
        }        
     }
 }
 
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

2 Replies

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

Answer by Lewance · Jan 12, 2016 at 01:12 AM

short code for getting something to only update every now and again - using dummy variables/functions for storing the direction, checking the direction and moving in it

 public float stepTime;
 private float nextStep;    
     void Update()
     {
         if (Time.time  > nextStep)
         {
             nextStep = Time.time + stepTime;
             direction =  CheckTheControlsForDirection();
         } 
        moveInDirection(direction);
     }
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
avatar image
0

Answer by IKilledKenny_2 · Jan 12, 2016 at 08:12 AM

I Love You! Thank you i have been stuck on this for days =D

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

63 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 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 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

Detect player movement 0 Answers

Set Bool to false after seconds? 2 Answers

Animation Issues - Won't play OnTriggerExit 0 Answers

How to pick up an object in hand e.g. a bat C# 0 Answers

player goes through the terrain and don't fall of of it 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