Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Player cant move

I followed Brackeys Multiplayer FPS tutorial and commpleted till ep 2 but the player is not moving at all Please tell what is the problem.

PlayerMotor

using UnityEngine;


[RequireComponent(typeof(Rigidbody))]
public class PlayerMotor : MonoBehaviour {
    
     private Vector3 velocity = Vector3.zero;


     private Rigidbody rb;


     void start () 
     {
         rb = GetComponent<Rigidbody>();
     }
    public void Move (Vector3 _velocity)
    {
        velocity = _velocity;
    }
  
    //Run every physics iteration
    void FixedUpdate ()
    {
        PerformMovement();
    }
    
    //Perform movement based on velocity variable
    void PerformMovement ()
    {
        if (velocity != Vector3.zero)
        {
            rb.MovePosition(rb.position + velocity * Time.fixedDeltaTime);
        }
    }


}


PlayerController

using UnityEngine;


[RequireComponent(typeof(PlayerMotor))]
public class PlayerController : MonoBehaviour {
    
    [SerializeField]
    private float speed = 5f;   


    private PlayerMotor motor;


    void start ()
    {
        motor = GetComponent<PlayerMotor>();
    }


    void update ()
    {
      //Calculate our movement velocity as a 3d vector
      float _xMov = Input.GetAxisRaw("Horizontal");
      float _zMov = Input.GetAxisRaw("Vertical");


      Vector3 _movHorizontal = transform.right * _xMov; 
      Vector3 _movVertical = transform.forward * _zMov; 


      //Final Movement Vector
      Vector3 _velocity = (_movHorizontal + _movVertical).normalized * speed; 
    
      //Apply Movement
      motor.Move(_velocity);
    
    }


}

This would really help me for my project please tell

Sign In or Register to comment.