I dont know why my player movement script isnt working

I also do everything from youtube tutorial

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour {
{
    public float walkSpeed;
    public float sprintSpeed;
    public float jumpHeight;

    [SerializeField] private float moveSpeed;

    private Rigidbody rb;

    // Use this for initialization
    void Start ()
    {
        rb = GetComponent<Rigidbody>();

        moveSpeed = walkSpeed;
    }
 
    // Update is called once per frame
    void Update ()
    {
        PlayerMove();
    }

    private void PlayerMove()
    {
        float MoveX = Input.GetAxis("Horizontal") * (moveSpeed * 0.8f) * Time.deltaTime;
        float MoveX = Input.GetAxis("Vertical") * moveSpeed * Time.deltaTime;

        if (Input.GetButton("Sprint"))
        {
            moveSpeed = sprintSpeed;
        }
        else
        {
            moveSpeed = walkSpeed;
        }


        if(Input.GetButtonDown("Jump"))
        {
            if(rb.velocity.y <= 0.1f && rb.velocity.y >= -0.1f)
            {
                rb.AddForce(new Vector3(rb.velocity.x, (rb.velocity.y + jumpHeight) * 10, rb.velocity.z));
            }
        }

        transform.Translate(new Vector3(MoveX, 0, MoveZ));
   
    }

}

6406375--715120--unity byczq.png

as you can see you have there 2 " { " , you need to remove one,

also one at the bottom

what lines

aight got it next error is

6406480--715129--mmm.png

ye well, you can ready the line where it happens :slight_smile:

the error says exactly what it is , you declared 2x the same variable

  • float MoveX = Input.GetAxis(“Horizontal”) * (moveSpeed * 0.8f) * Time.deltaTime;
  • float MoveX = Input.GetAxis(“Vertical”) * moveSpeed * Time.deltaTime;
        float MoveX = Input.GetAxis("Horizontal") * (moveSpeed * 0.8f) * Time.deltaTime;
        float MoveX = Input.GetAxis("Vertical") * moveSpeed * Time.deltaTime;

i dont get it what i need 2 do?

you need to declare for ea. value a different variable :slight_smile:

        float MoveX = Input.GetAxis("Horizontal") * (moveSpeed * 0.8f) * Time.deltaTime;
        float MoveY = Input.GetAxis("Vertical") * moveSpeed * Time.deltaTime;