"error CS0131: The left-hand side of an assignment must be a variable, a property or an indexer" (162401)

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class WygranaGry : Zdrowie {

	public GameObject przeciwnikObjekt;
	public Canvas wygrana;
	public float iloscPrzeciwnikow = 14;
	public Transform przeciwnikT;
	public float iloscOdjentychPrzeciwnikow = -1;

	// Use this for initialization
	void Start () {

		przeciwnikT = przeciwnikObjekt.transform;
		wygrana = wygrana.GetComponent<Canvas> ();
		przeciwnikObjekt = GameObject.FindWithTag ("Przeciwnik");
	
		wygrana.enabled = false;
	}
	
	// Update is called once per frame
	void Update () {
		if ((iloscPrzeciwnikow) <= 0) {
			PoWygraniuGry ();
		}

	}
	public void PokonanyPrzeciwnik (){
		if ((GameObject)przeciwnikObjekt = Destroy(gameObject)){
			iloscPrzeciwnikow = iloscPrzeciwnikow - (float)iloscOdjentychPrzeciwnikow;
		}

			}
	public void PoWygraniuGry(){
		Time.timeScale = 0;
		wygrana.enabled = true;
		Cursor.visible = true;
	}
}

I am a beginner developer, and my friend asked me if i could make a project with him to his school work. He is in a robotics class, and he asked me if i could make something that can try to guess the player's word. Basically, i will make a software that can guess words, and then he will make a "basic robot" that can work with my software. We will install it in the robot and try it. Our objective is, when someone types a word in the robot's keyboard, it try to guess it's word.

1 Answer

1

if ((GameObject)przeciwnikObjekt = Destroy(gameObject)){
Destroy returns void, so you cannot assign an object to Destroy. I don’t know what’s happening here, but I’ll guess:

public void PokonanyPrzeciwnik (){
	//if ((GameObject)przeciwnikObjekt = Destroy(gameObject)){
	Destroy(przeciwnikObjekt);
	iloscPrzeciwnikow = iloscPrzeciwnikow - (float)iloscOdjentychPrzeciwnikow;
	//}
}