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

Discussion RequiredComponent Not working

Discussion in 'Scripting' started by scrappedpixel64, Aug 13, 2023.

  1. scrappedpixel64

    scrappedpixel64

    Joined:
    Jun 15, 2023
    Posts:
    2
    I wanted to to add this RequiredComponent line of code to automatically add a character controller. However, I can't seem to get the Unity editor to accept my code. Been at this for an hour now.

    Here is my code (it has a problem when I add line ):
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.InputSystem;
    5.  
    6. namespace Advanced FPS Controller
    7. {
    8.     [RequiredComponent(typeof(CharacterController))]
    9.     public class InputSystem : MonoBehaviour
    10.     {
    11.         // Start is called before the first frame update
    12.         void Start()
    13.         {
    14.            
    15.         }
    16.  
    17.         // Update is called once per frame
    18.         void Update()
    19.         {
    20.            
    21.         }
    22.     }
    23. }
    Here are the errors that are generated:
    upload_2023-8-12_18-45-32.png

    Any and all help is appreciated!
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,769
  3. wideeyenow_unity

    wideeyenow_unity

    Joined:
    Oct 7, 2020
    Posts:
    728
  4. scrappedpixel64

    scrappedpixel64

    Joined:
    Jun 15, 2023
    Posts:
    2
    I see now thank you. The joy of programming stuff! Thank you in all seriousness.
     
    wideeyenow_unity likes this.
  5. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,900
    Do not call your own class InputSystem if you want anything good with it... you will mix it up with Unity's.
     
    CodeSmile and Ryiah like this.