Question by 
               dangYlovAhhh · Jul 24, 2017 at 09:24 AM · 
                c#errorgameobjectstring  
              
 
              error CS0019: Operator `==' cannot be applied to operands of type `UnityEngine.GameObject' and `string'
script:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class NewBehaviourScript : MonoBehaviour { UnityEngine.AI.NavMeshAgent playerAgent;
 void Start()
 {
     playerAgent = GetComponent<UnityEngine.AI.NavMeshAgent> ();
 }
 void Update () 
 {
     if (Input.GetMouseButtonDown (0) && !UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject ())
         GetInteraction ();
 }
 void GetInteraction ()
 {
     Ray interactionRay = Camera.main.ScreenPointToRay(Input.mousePosition);
     RaycastHit interactionInfo;
     if (Physics.Raycast(interactionRay, out interactionInfo, Mathf.Infinity))
     {
         GameObject interactedObject = interactionInfo.collider.gameObject;
         if (interactedObject == "Interactable Object") 
         {
             Debug.Log ("Interactable Interacted");
         }
             
         else 
         {
             playerAgent.destination = interactionInfo.point;
         }
     }
 }
 
               }
i have no idea for now why does this happen and im very confused with this " wrong" application of '==' for a string. please help
               Comment
              
 
               
              do you want to find object by name? use interactedObject.name=="Interactable Object" ins$$anonymous$$d
Your answer
 
             Follow this Question
Related Questions
Setting EventTrigger in Unity with JavaScript 0 Answers
Array index out of range(C#) 1 Answer
Can't add Orbital script - "The script needs to derive from MonoBehaviour!" 0 Answers
get_transform can only be called from the main thread error 1 Answer
I have a problem with error CS0116. line (3,5) ,(5,14). 0 Answers