- Home /
Put axises / emulate keys on texture buttons?
Hello, so here's my script for geared car on phone. I wonder why i am not getting any reaction when i try to press the up texture button. Am i even close to understand how to put axises in to button.
It'd be awesome if you can find me the answer!! :)
 var enginePower=150.0;
  var up : GUITexture;
  var Magni : float;
  
  private var axisH: float = 0; 
  private var axisV: float = 0;
   
   function InputGetAxis(axis: String): float {
   
       var v = Input.GetAxis(axis);
       if (Mathf.Abs(v) > 0.005) return v;
       if (axis=="Horizontal") return axisH;
       if (axis=="Vertical") return axisV;
       
   }
          
  function Start(){
  axisV = axisH = 0;
  } 
  
  function Update () {
  
  for (var touch : Touch in Input.touches){ 
  
  if(touch.phase == TouchPhase.Stationary && up.HitTest (touch.position)){
      if (Magni >= 0){
          axisH = 1 * enginePower * Time.deltaTime * 600.0;
       }
      if (Magni > 50){
          axisH = 1 * enginePower * Time.deltaTime * 250.0;
       } 
          if (Magni > 100){
          axisH = 1 * enginePower * Time.deltaTime * 100.0;
       } 
              if (Magni > 110){
          axisH = 1 * enginePower * Time.deltaTime * 80.0;
       }
               if (Magni > 130){
          axisH= 1 * enginePower * Time.deltaTime * 30.0;
       } 
          }
  }
  
  }
  
Answer by tanoshimi · Dec 23, 2014 at 08:24 AM
HitTest expects screen coordinates. Input.position returns pixel coordinates. Try subtracting from Screen.height.
http://docs.unity3d.com/ScriptReference/GUIElement.HitTest.html
Your answer
 
 
             Follow this Question
Related Questions
How do I clamp a texture only on the y axis, but repeat on the x axis? 0 Answers
One atlas per scene or one (larger) atlas across multiple scenes? 0 Answers
How can I make my car turn? 1 Answer
Material texture artefact on mobile platforms 1 Answer
Mobile optimised simple car physics? Any recommendation? 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                