Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question CS00029 cannot implicitly convert type "string" to "bool"

Discussion in 'Editor & General Support' started by OJPgames, Aug 23, 2023.

  1. OJPgames

    OJPgames

    Joined:
    Aug 22, 2023
    Posts:
    4
    The code is not done dont worry about the debug log idc about that please help me with the error
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class PlayerCollision : MonoBehaviour
    4. {
    5.     public Movement movement;
    6.     void OnCollisionEnter(Collision collisionInfo)
    7.     {
    8.         if (collisionInfo.collider.tag = "Obstacle")
    9.         {
    10.             Debug.Log("youded");
    11.         }
    12.  
    13.        
    14.        
    15.     }
    16. }
    17.  
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,856
    One
    =
    is used for assignment, two
    ==
    are used to make comparisons.
     
  3. BABIA_GameStudio

    BABIA_GameStudio

    Joined:
    Mar 31, 2020
    Posts:
    488
    On line 8 you are supposed to be using
    ==
    for comparing. What you are currently doing is trying to assign the string "Obstacle" into the tag property of the colliding object.
     = 
    is for assigning
     == 
    is for comparisons

    Edit: Damn, ninja'd.
     
  4. OJPgames

    OJPgames

    Joined:
    Aug 22, 2023
    Posts:
    4
    thanks