Input. Getaxis usage:
(Getaxis ("Mouse X"),
Getaxis ("Mouse Y"),
Getaxis ("Mouse scrollwheel"),
Getaxis ("Vertical"),
Getaxis ("Horizontal"),
Getaxis is a method that needs to be passed a parameter with a string type, with the following parameters:
One: Touch screen class
1.Mouse x Mouse is triggered as it moves along the screen x
2.Mouse y Mouse is triggered as it moves along the screen y
3.Mouse Scrollwheel triggered when the mouse scroll wheel is scrolling
Two: Keyboard Operation class
1.Vertical the upper and lower arrows above the keyboard, triggered when the up or down arrows are pressed
2.Horizontal corresponds to the left and right arrows on the keyboard, which is triggered when an arrow is pressed
As an example:
1 voidUpdate ()2 {3 //2-Get axis information4 floatINPUTX = Input.getaxis ("Horizontal");5 floatInputy = Input.getaxis ("Vertical");6 7 //3-Save motion trajectory8Movement =NewVector2 (speed.x * inputx, SPEED.Y *inputy);9}
Use W, S, A, D to move up or down, respectively.
Unity3d input. Getaxis