Search Unity

i need helppp please...

Discussion in 'Editor & General Support' started by IRaptor1212, May 1, 2019.

  1. IRaptor1212

    IRaptor1212

    Joined:
    Feb 26, 2018
    Posts:
    2
    i have this script .. and not work ..

    //script

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class ItemIndicator : MonoBehaviour
    {

    public FPSItemPlacing Itemplacing;
    public bool _isInObject = false;
    public GameObject ItemIndicatorNo;
    public Renderer rend;

    void Start ()
    {
    rend = GetComponent<Renderer>();
    rend.enabled = true;
    if (Itemplacing == null)
    Itemplacing = GameObject.FindGameObjectsWithTag("BuildingPlan");

    }

    //error

    error CS0029: Cannot implicitly convert type `UnityEngine.GameObject[]' to `FPSItemPlacing'
     
  2. NicBischoff

    NicBischoff

    Joined:
    Mar 19, 2014
    Posts:
    204
    What is FPSItemPlacing. There is your problem. Also, Use braces for your if statement.
    Lower case names to start variables.
     
  3. Cubemaster465

    Cubemaster465

    Joined:
    Mar 6, 2018
    Posts:
    2
    You're doing 2 things wrong. You're trying to give a value to a variable which isn't possible. For example, you can't put text in an int variable. I don't know what a FPSItemPlacing is and if it can be a GameObject, but i suggest you try to change the type of Itemplacing to GameObject. And the second problem is that you're trying to put an array in a variable which isn't an array. So you also have to change Itemplacing to an array.