Home>

Lateral movement suddenly stopped moving in unity, so I want to improve it.
I searched for questions and tried various methods
It does not solve.

If i were editing Animation or Animator.
In a script that controls the character
No longer move sideways.
I can jump for some reason.

Corresponding source code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class novaControler: MonoBehaviour {
    // common
    public GameObject mainCamera;
    Rigidbody2D rb2d;
    Animator anim;
    //attack
    int attackNum;
    // move
    public float Runspeed = 10.0f;
    public float Scroll = 1.0f;
    // Jump
    public float jumpPower = 700;
    public LayerMask groundLayer;
    public float velY;
    private bool isGrounded;
    // Use this for initialization
    void Start () {
        anim = GetComponent  ();
        rb2d = GetComponent<Rigidbody2D>();
    }
    // Update is called once per frame
    void Update () {
        velY = rb2d.velocity.y;
        bool isJumping = velY>0.1? true: false;
        bool isFalling = velY<-0.1f? true: false;
        anim.SetBool ("is jumping", is Jumping);
        anim.SetBool ("isfalling", isFalling);
        if (Input.GetKey (KeyCode.LeftArrow) || Input.GetKey (KeyCode.RightArrow)) {
            move ();
        } else {
            anim.SetBool ("walk", false);
        }
        if (Input.GetKeyDown (KeyCode.Space)) {
        jump ();
        } else if (Input.GetKey (KeyCode.Z)) {
            attack ();
        } else if (Input.GetKey (KeyCode.X)) {
            gun ();
        }
    }
    void jump () {
        isGrounded = Physics2D.Linecast (transform.position + transform.up * 1, transform.position --transform.up * 1f, groundLayer);
        Debug.DrawLine (transform.position + transform.up * 1, transform.position --transform.up * 1f, Color.red);
        if (Input.GetKey (KeyCode.Space)) {
            if (isGrounded) {
                anim.SetBool ("walk", false);
                anim.SetTrigger ("jump");
                isGrounded = false;
                rb2d.AddForce (Vector2.up * jumpPower);
            }
        }
    }
    void move () {
        Vector2 direction = transform.localScale;
        if (Input.GetKey (KeyCode.RightArrow)) {
            direction.x = 6;
            anim.SetBool ("walk", true);
            rb2d.velocity = new Vector2 (Scroll * 1 * Runspeed, rb2d.velocity.y);
        } else if (Input.GetKey (KeyCode.LeftArrow)) {
            direction.x = -6;
            rb2d.velocity = new Vector2 (Scroll * -1 * Runspeed, rb2d.velocity.y);
            anim.SetBool ("walk", true);
        } else {
        }
        transform.localScale = direction;
    }
    void attack () {
        if (attackNum == 0) {
            anim.SetInteger ("attack", 1);
        }
    }
    void gun () {
    }
}
What I tried

Turn on/off Animator, Script, SpriteRender, BoxCollider2D, CircleCollider
Remove Component for RigidBody2D.
Remove the child object.

Supplementary information (FW/tool version, etc.)

Unity 5.6.71f 32bit
SharpDevelop version: 5.1.0