Nightmares - Character does not move, stopped in Idle animation

Asked

Viewed 651 times

3

I am following the step by step of Nightmares in Unity3d, but following the tutorials of Nils I came across a problem, after finishing the script the character does not move on the test screen, it stands still in Idle animation, and it does not continue, load only 1 time. Thanks for the help, big hug!

inserir a descrição da imagem aqui

using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    public float speed = 6f;                //Velocidade do jogador

    Vector3 movement;                       //Vetor responsavel pelo movimento
    Animator anim;                          //Responsavel pela transiçao da animaçao 
    Rigidbody playerRigidbody;              //Responsavel pela fisica do objeto
    int floorMask;                              //Mascara de chao
    float camRayLenght = 100f;              //Informaçoes para o raycast

    void Awake ()
    {
        //Atribuir a mascara da camada. 
        floorMask = LayerMask.GetMask("Floor");

        //Atribuir as referencias.
        anim = GetComponent <Animator> ();
        playerRigidbody = GetComponent <Rigidbody> ();

    }

    void FixedUpadate()
    {
        float h = Input.GetAxisRaw ("Horizontal");
        float v = Input.GetAxisRaw ("Vertical");
        Move(h,v);
        turning();
        Animating(h,v); 

    }

    //Movimenta o jogador
    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 no personagem
        playerRigidbody.MovePosition (transform.position + movement);
    }

    //Gira o jogador
    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);
            playerRigidbody.MoveRotation(newRotation);


        }

    }
    void Animating(float h, float v)
    {
        bool walking = (h!= 0f || v!= 0f);
        anim.SetBool("IsWalking", walking);

    }


}
  • Hi I’m having the same problem.. Kk' Waiting for a reply tbm haha. But Aki.. By the way you tbm ta trying to learn and tals.. How old are you? xD

  • Come on, buddy, I’m 24. It is, I believe that several people had the same problem, I remade the tutorial from scratch twice to remove doubt on the question of variables and functions, this part of programming is very complicated because the interpretation is Case Sensitive, but it did not work at all. I don’t want to wait until starting the C++ module in the course to start programming so I’m already putting some things into practice. I just hope it doesn’t take too long to resolve this issue, I have this 10:00 problem and so far I haven’t found a solution!

  • Add me to Steam ai: Sardovick

  • Added Luke. Old I was outraged by the problem and looking for a solution I ended up entering in Answers.Unity, I realized that several people had the same problem after upgrading to version 5. I do not know in which version you are developing, But all the tutorials I found of this game there were not these two boxes in the nodes, Entry and Exit, I have my suspicions that some configuration is missing in these nodes there. I’ll see if Nils answers me on Youtube.

  • Look out guys, Entry and Exit has nothing to do with the problem, they are solutions to make life easier when they are doing other things. Because of a line in the code you are spreading misinformation that can get in the way of others who are learning.

  • @Lucas what was your problem?

  • Because of a similar question, this question is also being discussed at the goal. I also voted to close it because it’s essentially a typo.

Show 2 more comments

1 answer

2


  • Thanks Nils gave it right here is running naughty now. Strong hug!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.