ERROR: 'RequestOwnership' is a type, which is not valid in the given context

So I’m making a system so that players in a server can interact with objects but when I call ‘RequestOwnership()’ I just get the same error over and over again. I am using unity version 2021.3.23f1. The error is coming from 20,81. The error is in this line: ‘private void OnDisable() => xRGrabInteractable.selectEntered.RemoveListener(RequestOwnership);’.

Here’s my code:

using Normal.Realtime;
using UnityEngine.XR.Interaction.Toolkit;
using UnityEngine;

public class RequestOwnership : MonoBehaviour
[SerializeField] private RealtimeView realtimeView;
[SerializeField] private RealtimeTransform realtimeTransform;
[SerializeField] private XRGrabInteractable xRGrabInteractable;

private void OnEnable() => xRGrabInteractable.selectEntered.AddListener(RequestObjectOwnership);

private void RequestObjectOwnership(SelectEnterEventArgs args)

private void OnDisable() => xRGrabInteractable.selectEntered.RemoveListener(RequestOwnership);


I think that last line is supposed to be RemoveListener(RequestObjectOwnership)


1 Like