(Unity3D) Error in character animation | Nightmare - Unity Training Day

0

I'm watching the videos in the playlist ( link ) and I'm having a little problem performing the lesson's procedures # 02 ( link ).

I animated the character, wrote the movement code and rotation of it, did everything that is shown in the video, however, when playing the game, the character does not perform the move animation, it slides and, after a long time, the animation is executed. One of the main problems is that the whole process repeats itself if I stop pressing the movement keys and try to move it quickly. In short, the movement is instant, but the animation is not.

The images that I will attach will correspond to the INSPECTOR of the animations "MOVE" and "IDLE", as well as an error that is being displayed in the Unity3D interface. I will provide the code of the game also, which by the way, is almost identical to the video.

PS: The version of Unity3D I'm using is 2017.3.1f1.

PS1: I saw some similar posts, but I did not find a solution in any of them.

    using UnityEngine;

    public class PlayerMovement : MonoBehaviour {

    public float speed = 6f;        // Velocidade do Player.

    Vector3 movement;               // Vetor responsável pelo movimento.
    Animator anim;                  // Responsável pela transição da animação.
    Rigidbody playerRigidboyd;      // Responsável pela física do objeto.
    int floorMask;                  // Máscara de chão.
    float camRayLenght = 100f;      // Informações do raycast.

    void Awake() {

        // Atribuir a máscara da camada.
        floorMask = LayerMask.GetMask ("Floor");

        // Atribuir as referências.
        anim = GetComponent <Animator>  ();
        playerRigidboyd = GetComponent <Rigidbody> ();

    }

    void FixedUpdate() {

        float h = Input.GetAxisRaw ("Horizontal");
        float v = Input.GetAxisRaw ("Vertical");

        Move (h, v);
        Turning ();
        Animating (h, v);

    }

    // Movimenta o player.
    void Move (float h, float v) {

        // Determina o movimento.
        movement.Set (h,0f,v);

        // Normaliza o movimento.
        movement = movement.normalized * speed * Time.deltaTime;

        // Efetua o movimento do Player.
        playerRigidboyd.MovePosition (transform.position + movement);

    }

    // Gira o player.
    void Turning () {

        Ray camRay = Camera.main.ScreenPointToRay (Input.mousePosition);

        RaycastHit floorHit;

        if (Physics.Raycast (camRay, out floorHit, camRayLenght, floorMask)) {

            Vector3 playerToMouse = floorHit.point - transform.position;
            playerToMouse.y = 0f;

            Quaternion newRotation = Quaternion.LookRotation (playerToMouse);
            playerRigidboyd.MoveRotation (newRotation);

        }
    }

    void Animating (float h, float v) {

        bool walking = h != 0f || v != 0f;
        anim.SetBool ("IsWalking", walking);

    }
}

[IMAGES]

  • Animator & Game - link
  • InspectorIDLE - link
  • InspectorMove - link
  • asked by anonymous 17.03.2018 / 21:34

    0 answers