input - Unity 2d Platformer Controller support -


I am currently trying to create 2D platforms in unity, everything is working fine except for one task . When I suppress the left or right, my phantom animation is a mirror in the right direction. I am currently trying to add controller input, but I can not aim to push analog left or right

Hope someone can help me :)

< Pre> #pragma Strict Works X: Float; Start function () {// normal object scale X = transform. Local Scale. Gathering X; } Function Update () {if (Input.GetKey ("a")) {// Gamer Left Arrow Key / Set Change Texture to Normal Position Localecc.x = -X; } Else if (Input.GetKey ("d")) {// gamer puts the right arrow key / flip texture transform.localScale.x = X; } If (Input.GetKey ("left")) {// gamer changed the left arrow key / set texture to normal position. LocalScale.x = -X; } Else if (Input.GetKey ("right")) {// gamer puts the right arrow key / flip texture transform. Localecc.x = X; } If (Input.GetAxis ("Horizontal")) {// Gamer has changed the left arrow key / set texture to a normal position. LocalScale.x = -X; } Else if (Input.GetAxis ("Horizontal")) {// Gamer Right Arrow Keys / Flip Textures transform.localScale.x = X; }}

You have it:

  If (Input.GetAxis ("horizontal")) // // gamer turns left arrow key / set texture to normal position. Localecc.x = -X; } Else if (Input.GetAxis ("Horizontal")) {// Gamer Right Arrow Keys / Flip Textures transform.localScale.x = X; }  

Second and if always called because you are checking the same input. Gatexis ().

It:

  if (input. Getexes ("horizontal") <0) {transform.localScale.x = -X; } And if (Input. Getexes ("Horizontal")> 0) {transform.localScale.x = X; }  

Input.GetAxis ("horizontal") checks all the left and right keys on the left or right keys, which can be suppressed by a number ...

Example If I press the 'Left Arrow' key, then it will return a number between 0 and -1. If I hold the 'Right Arrow' key, it will return a number between 0 and 1.

Does this make sense?


Comments