me_camel
me_camel
CC#
Created by me_camel on 7/20/2024 in #help
Choppy text
No description
14 replies
CC#
Created by me_camel on 7/20/2024 in #help
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,
C#
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);
}
}
}
}
C#
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
22 replies