Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

error CS0111 (help)

Discussion in 'Scripting' started by GoldenMine12, Oct 24, 2020.

  1. GoldenMine12

    GoldenMine12

    Joined:
    Oct 22, 2020
    Posts:
    38
    i have this error in my code and i dont know what to do about it please help:

    Assets\scripts\controller\Movement.cs(17,10): error CS0111: Type 'Movement' already defines a member called 'Start' with the same parameter types

    Code (csharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. public class Movement : MonoBehaviour
    7. {
    8.     float Speed;
    9.  
    10.     public Rigidbody rb;
    11.     public bool PlayerOnGround = true;
    12.  
    13.     private void Start()
    14.     {
    15.         rb = GetComponent<Rigidbody>();
    16.     }
    17.     // Start is called before the first frame update
    18.     void Start()
    19.     {
    20.         Speed = 5;
    21.     }
    22.  
    23.     // Update is called once per frame
    24.     void Update()
    25.     {
    26.         transform.Translate(Input.GetAxis("Horizontal") * Time.deltaTime * Speed, 0, Input.GetAxis("Vertical") * Time.deltaTime * Speed);
    27.  
    28.         if(Input.GetKey(KeyCode.UpArrow)) {
    29.             transform.Translate(5, 0, 10 * Time.deltaTime);
    30.         }
    31.         if(Input.GetKey(KeyCode.DownArrow)) {
    32.             transform.Translate(5, 0, -10 * Time.deltaTime);
    33.         }
    34.         if(Input.GetKey(KeyCode.LeftArrow)) {
    35.             transform.Translate(-10 * Time.deltaTime, 0, 0);
    36.         }
    37.         if(Input.GetKey(KeyCode.RightArrow)) {
    38.             transform.Translate(10 * Time.deltaTime, 0, 0);
    39.         }
    40.         if(Input.GetButtonDown("w")) {
    41.             if(Input.GetButtonDown("left shift")){
    42.                 transform.Translate(10 * Time.deltaTime * 3f, 0, 0);
    43.             }
    44.            
    45.         }
    46.        
    47.         if(Input.GetButtonDown("jump") && PlayerOnGround)
    48.         {
    49.             rb.AddForce(new Vector3(0, 5, 0), ForceMode.Impulse);
    50.             PlayerOnGround = false;
    51.         }
    52.     }
    53.  
    54.     private void OnCollisionEnter(Collision collision)
    55.     {
    56.         if(collisionn.gameObject.tag == "ground")
    57.         {
    58.             PlayerOnGround = true;
    59.         }
    60.     }
    61. }
    62.  
    63. [code]
     
  2. Terraya

    Terraya

    Joined:
    Mar 8, 2018
    Posts:
    646
    you have 2x the same function

    Code (CSharp):
    1.     private void Start()
    2.     {
    3.         rb = GetComponent<Rigidbody>();
    4.     }
    5.     // Start is called before the first frame update
    6.     void Start()
    7.     {
    8.         Speed = 5;
    9.     }
    10.  
    change it to:

    Code (CSharp):
    1. private void Start()
    2.     {
    3.         rb = GetComponent<Rigidbody>();
    4.         Speed = 5;
    5.     }
     
  3. GoldenMine12

    GoldenMine12

    Joined:
    Oct 22, 2020
    Posts:
    38
    thank you