I don't understand what this error means

I am trying to get a reference for the transform of a sprite but I have a yellow line under
Transform transform; When I click on view problem unity gives me this ‘PlayerControl.transform’ hides inherited member ‘Component.transform’. Use the new keyword if hiding was intended. [Assembly-CSharp]csharp(CS0108). I was wondering if anyone could give me an explanation of this error or how to fix it. Thank you

//This is my code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerControl : MonoBehaviour
{
Transform transform;

void Start()
{
   
}
void Update()
{
   
}

void OnMove(InputValue value)
{
print(“hi”);
}
}

I have actually figured out how to solve this problem.

Just for completeness, you cannot name variables something that already exist on an object. MonoBehaviour already has a member called transform, so you are not allowed to use the same name for your own variable.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms