0

The error messages say

'Assets/Scripts/PlayerMovement.cs(5,14): error CS0101: The namespace '<global namespace>' already contains a definition for 'PlayerMovement' Assets/Scripts/PlayerMovement.cs(12,10): error CS0111: Type 'PlayerMovement' already defines a member called 'Start' with the same parameter types Assets/Scripts/PlayerMovement.cs(18,10): error CS0111: Type 'PlayerMovement' already defines a member called 'Update' with the same parameter types'

Here's my code:

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

public class PlayerMovement : MonoBehaviour
{
    Rigidbody rb;

    [SerializeField] float movementSpeed = 6f;
    [SerializeField] float jumpForce = 5f;

    [SerializeField] Transform groundCheck;
    [SerializeField] LayerMask ground;

    // Start is called before the first frame update
    void Start() {  
        rb = GetComponent<Rigidbody>();
    }

    // Update is called once per frame
    void Update()
    {

        float horizontalInput = Input.GetAxis("Horizontal");
        float verticalInput = Input.GetAxis("Vertical");

        rb.velocity = new Vector3(horizontalInput * movementSpeed, rb.velocity.y, verticalInput * movementSpeed);

        if (Input.GetButtonDown("Jump")) {
            rb.velocity = new Vector3(rb.velocity.x, jumpForce, rb.velocity.z);
        }  
    }
 
    bool IsGrounded() {
        Physics.CheckSphere(groundCheck.position, .1f, ground);
    }
    
}

How can I fix this? This is the only script in my project. I've looked through all similar questions and nothing has helped. I'm a beginner.

halfer
  • 19,824
  • 17
  • 99
  • 186
  • 3
    Looks like there are two scripts in the project with class `PlayerMovement` – Geeky Quentin Aug 13 '22 at 09:41
  • Plenty of [duplicates here](https://stackoverflow.com/search?tab=relevance&q=The%20namespace%20%27%3cglobal%20namespace%3e%27%20already%20contains%20a%20definition%20for%20). – halfer Aug 13 '22 at 10:12
  • 1
    This post has been added to the review queue via some trivial edits, but IMO reopening is not warranted. There is no indicator that the others are not duplicates other than the unsubstantiated "nothing helped". – halfer Aug 13 '22 at 21:37

0 Answers0