- Home /
Joystick DPad axis to bool
Hello,
I want to have a class in the inspector to debug those variables.
I have problems on the get/set method in the declarisation section. Is there a way on how to set them at runtime without using in Update, just in the declarisation section?
 [System.Serializable]
 public class DPad {
     public bool left { get { return this; } set { Input.GetAxisRaw("DPAD_X") < 0; } }
     public bool right { get { return this; } set { Input.GetAxisRaw("DPAD_X") > 0; } }
     public bool up { get { return this; } set { Input.GetAxisRaw("DPAD_Y") > 0; } }
     public bool down { get { return this; } set { Input.GetAxisRaw("DPAD_Y") < 0; } }
 }
 [SerializeField]
 public DPad dpad;
 void Start() { ... }
This gives me an Only assignment, call, increment, decrement, and new object expressions can be used as a statement error.
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by NerdClown · Sep 05, 2016 at 11:39 AM
Try something like this in stead:
 public bool left 
 { 
   get 
   { 
     return Input.GetAxisRaw("DPAD_X") < 0; 
    } 
  }
For each of the four, of course.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                