0

I am making a vr game and I am using UnityXR to do so. I am making a script that will have two attach points for an object (pistol). These points change based on which hand is holding the object.

Here is my code:

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;

public class XRGrabIneractableTwoAttach : XRGrabInteractable
{
    public Transform leftAttachTransform;
    public Transform rightAttachTransform;

    protected override void OnSelectEntered(SelectEnterEventArgs args)
    {
        if(args.interactableObject.transform.CompareTag("Left Hand"))
        {
            attachTransform = leftAttachTransform;
        }
        else if(args.interactableObject.transform.CompareTag("Right Hand"))
        {
            attachTransform = rightAttachTransform;
        }

        base.OnSelectEntered(args);
    }

}

However, when I save my code and go into Unity, it gives me this. "The associated script can not be loaded. Please fix any compile errors and assign a valid script." I have absolutely no idea how to fix this as the code looks fine to me. Can someone please help me with this?

BumbleFuzzz
  • 15
  • 1
  • 3
  • 2
    Can you confirm the script file name is exactly matching with `XRGrabIneractableTwoAttach.cs` ? Note that there is a typo: missing `t` in `Interactable` .. if the class name doesn't match exactly with the script file name then Unity doesn't find it – derHugo Dec 27 '22 at 09:46
  • @derHugo that was the problem! i forgot to respond to this, thank you so much for your help. – BumbleFuzzz Jan 19 '23 at 12:53

0 Answers0