- Home /
C# Input.GetAxis Increment/Decrement Value
What value is used when you press a key to increase/decrease an Axis? I'm trying to make my own custom input.getAxis script and would like to know. I tried using Time.deltaTime but it seems off when I compare it to the regular input.getaxis.
 using UnityEngine;
 using System.Collections;
 
 public class CustomAxis : MonoBehaviour {
 public string[] inputStrings;
 public float axis;
 
     void Update () {
         if (Input.GetKey(inputStrings[0])){
             if(axis < 1){
                 axis += Time.deltaTime;
             }
         }
         if (Input.GetKey(inputStrings[1])){
             if(axis > -1){
                 axis -= Time.deltaTime;
             }
         }
         if (!Input.anyKey){
             if(axis < 0){
                 axis += Time.deltaTime;
             }
             if(axis > 0){
                 axis -= Time.deltaTime;
             }        
         }
     }
 }
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Double tap mechanics and axis inputs 3 Answers
Achieve framerate independent AddTorque rotaion with mouse drag. 2 Answers
how to increase or decrease ammo ?? but depending of ammo in inventory 1 Answer
Multiple Cars not working 1 Answer
How can i randomly increase/decrease a value over time? 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                