Skip to main content
added 104 characters in body; edited tags
Source Link
Matthew
  • 101
  • 2

I'm building a Raycast setup where game objects run code on click / touch.

if (Physics.Raycast(transform.position, transform.forward, out RaycastHit hit, maxDistance, interactableLayers))
     {
        
         if  (Input.GetButtonDown("Fire1"))
         {
             if (hit.collider != null) 
             { 

             currentInteractable = hit.collider.GetComponent<Interactable>();

             Debug.Log(hit.collider.name);

             }
         }

I'm following a tutorial where I must use an Interface to configure OnClick Actions for each game object:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 // public class Interactable : MonoBehaviour 
 
 // {
 
   public interface Interactable 
   {
 
     void onClickAction(); 
 
   }

However, I'm receiving a bunch of errors! I can't add this Interactable script to my game object and receive the error: "Can't add script behaviour Interactable. The script class can't be abstract!"

I also see in the console: "'Interactable' is missing the class attribute 'ExtensionOfNativeClass'!"

Why is this happening?

I'm building a Raycast setup where game objects run code on click / touch.

if (Physics.Raycast(transform.position, transform.forward, out RaycastHit hit, maxDistance, interactableLayers))
     {
        
         if  (Input.GetButtonDown("Fire1"))
         {
             if (hit.collider != null) 
             { 

             currentInteractable = hit.collider.GetComponent<Interactable>();

             Debug.Log(hit.collider.name);

             }
         }

I'm following a tutorial where I must use an Interface to configure OnClick Actions for each game object:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 // public class Interactable : MonoBehaviour 
 
 // {
 
   public interface Interactable 
   {
 
     void onClickAction(); 
 
   }

However, I'm receiving a bunch of errors! I can't add this Interactable script to my game object and receive the error: "Can't add script behaviour Interactable. The script class can't be abstract!"

Why is this happening?

I'm building a Raycast setup where game objects run code on click / touch.

if (Physics.Raycast(transform.position, transform.forward, out RaycastHit hit, maxDistance, interactableLayers))
     {
        
         if  (Input.GetButtonDown("Fire1"))
         {
             if (hit.collider != null) 
             { 

             currentInteractable = hit.collider.GetComponent<Interactable>();

             Debug.Log(hit.collider.name);

             }
         }

I'm following a tutorial where I must use an Interface to configure OnClick Actions for each game object:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 // public class Interactable : MonoBehaviour 
 
 // {
 
   public interface Interactable 
   {
 
     void onClickAction(); 
 
   }

However, I'm receiving a bunch of errors! I can't add this Interactable script to my game object and receive the error: "Can't add script behaviour Interactable. The script class can't be abstract!"

I also see in the console: "'Interactable' is missing the class attribute 'ExtensionOfNativeClass'!"

Why is this happening?

edited tags
Link
Theraot
  • 28.2k
  • 4
  • 55
  • 83
Source Link
Matthew
  • 101
  • 2

Can't add script behaviour Interactable. The script class can't be abstract!

I'm building a Raycast setup where game objects run code on click / touch.

if (Physics.Raycast(transform.position, transform.forward, out RaycastHit hit, maxDistance, interactableLayers))
     {
        
         if  (Input.GetButtonDown("Fire1"))
         {
             if (hit.collider != null) 
             { 

             currentInteractable = hit.collider.GetComponent<Interactable>();

             Debug.Log(hit.collider.name);

             }
         }

I'm following a tutorial where I must use an Interface to configure OnClick Actions for each game object:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 // public class Interactable : MonoBehaviour 
 
 // {
 
   public interface Interactable 
   {
 
     void onClickAction(); 
 
   }

However, I'm receiving a bunch of errors! I can't add this Interactable script to my game object and receive the error: "Can't add script behaviour Interactable. The script class can't be abstract!"

Why is this happening?