© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
21 replies
me_camel

can somebody help me,

can somebody help me, i keep getting the error , "PlayerInteract.cs(21,10):error CS0111: Type 'PlayerInteract' already defines a member called 'Update' with the same parameter types" my code is,
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerInteract : MonoBehaviour
{
    private Camera cam;
    [SerializeField]
    private float distance = 3f;
    [SerializeField]
    private LayerMask mask;
    private PlayerUI playerUI;
    // Start is called before the first frame update
    void Start()
    {
        cam = GetComponent<PlayerLook>().cam;
        playerUI = GetComponent<PlayerUI>();
    }

    // Update is called once per frame
    void Update()
    {
        playerUI.UpdateText(string.Empty);
       // Create a ray at the center of the camera, shooting outwards
       Ray ray = new Ray(cam.transform.position, cam.transform.forward);
       Debug.DrawRay(ray.origin, ray.direction * distance);
       RaycastHit hitInfo; // Variable to store the collision information
       if (Physics.Raycast(ray, out hitInfo, distance, mask))
       {
            if (hitInfo.collider.GetComponent<Interactable>() != null)
            {
                playerUI.UpdateText(hitInfo.collider.GetComponent<Interactable>().promptMessage);
            }
        }
    }
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerInteract : MonoBehaviour
{
    private Camera cam;
    [SerializeField]
    private float distance = 3f;
    [SerializeField]
    private LayerMask mask;
    private PlayerUI playerUI;
    // Start is called before the first frame update
    void Start()
    {
        cam = GetComponent<PlayerLook>().cam;
        playerUI = GetComponent<PlayerUI>();
    }

    // Update is called once per frame
    void Update()
    {
        playerUI.UpdateText(string.Empty);
       // Create a ray at the center of the camera, shooting outwards
       Ray ray = new Ray(cam.transform.position, cam.transform.forward);
       Debug.DrawRay(ray.origin, ray.direction * distance);
       RaycastHit hitInfo; // Variable to store the collision information
       if (Physics.Raycast(ray, out hitInfo, distance, mask))
       {
            if (hitInfo.collider.GetComponent<Interactable>() != null)
            {
                playerUI.UpdateText(hitInfo.collider.GetComponent<Interactable>().promptMessage);
            }
        }
    }
}

and i can ss my code
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

can somebody help me debug
C#CC# / help
3y ago
Please can somebody help me with this .txt file?
C#CC# / help
14mo ago
✅ can somebody help me learn about smtp so i can make a email message sender please
C#CC# / help
17mo ago
can someone help me:(
C#CC# / help
2y ago