Skip to main content
Became Hot Network Question
deleted 4 characters in body
Source Link

I'm currently working on a game strategy game and I just started working on it.

Here is the first script:

using UnityEngine;

public class Village : MonoBehaviour
{
    public int strength;
    private int x;

    private void Start()
    {
        StrengthValue();
        strength = x;

        print(gameObject.name + " ---- " + strength);
    }

    private void Update()
    {
        if (Input.GetMouseButtonDownGetMouseButton(0) && GameObject.Find("Game Manager").GetComponent<GameManager>().ArmySize > strength)
        {
            Destroy(gameObject);
        }
    }

    private void StrengthValue()
    {
       x = Random.Range(10, 500);
    }
}

here is the second script:

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

public class GameManager : MonoBehaviour
{
    public int ArmySize = 100;
}

All I want is for the game to detect when the player clicked a certain village. But I just can't figure it out since I'm pretty new to c# and unity. The scripts should be self-explanitory, but if you need more details please ask.

I'm currently working on a game strategy game and I just started working on it.

Here is the first script:

using UnityEngine;

public class Village : MonoBehaviour
{
    public int strength;
    private int x;

    private void Start()
    {
        StrengthValue();
        strength = x;

        print(gameObject.name + " ---- " + strength);
    }

    private void Update()
    {
        if (Input.GetMouseButtonDown(0) && GameObject.Find("Game Manager").GetComponent<GameManager>().ArmySize > strength)
        {
            Destroy(gameObject);
        }
    }

    private void StrengthValue()
    {
       x = Random.Range(10, 500);
    }
}

here is the second script:

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

public class GameManager : MonoBehaviour
{
    public int ArmySize = 100;
}

All I want is for the game to detect when the player clicked a certain village. But I just can't figure it out since I'm pretty new to c# and unity. The scripts should be self-explanitory, but if you need more details please ask.

I'm currently working on a game strategy game and I just started working on it.

Here is the first script:

using UnityEngine;

public class Village : MonoBehaviour
{
    public int strength;
    private int x;

    private void Start()
    {
        StrengthValue();
        strength = x;

        print(gameObject.name + " ---- " + strength);
    }

    private void Update()
    {
        if (Input.GetMouseButton(0) && GameObject.Find("Game Manager").GetComponent<GameManager>().ArmySize > strength)
        {
            Destroy(gameObject);
        }
    }

    private void StrengthValue()
    {
       x = Random.Range(10, 500);
    }
}

here is the second script:

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

public class GameManager : MonoBehaviour
{
    public int ArmySize = 100;
}

All I want is for the game to detect when the player clicked a certain village. But I just can't figure it out since I'm pretty new to c# and unity. The scripts should be self-explanitory, but if you need more details please ask.

Source Link

All objects are destroyed when I click left mouse button. | Unity 2D C#

I'm currently working on a game strategy game and I just started working on it.

Here is the first script:

using UnityEngine;

public class Village : MonoBehaviour
{
    public int strength;
    private int x;

    private void Start()
    {
        StrengthValue();
        strength = x;

        print(gameObject.name + " ---- " + strength);
    }

    private void Update()
    {
        if (Input.GetMouseButtonDown(0) && GameObject.Find("Game Manager").GetComponent<GameManager>().ArmySize > strength)
        {
            Destroy(gameObject);
        }
    }

    private void StrengthValue()
    {
       x = Random.Range(10, 500);
    }
}

here is the second script:

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

public class GameManager : MonoBehaviour
{
    public int ArmySize = 100;
}

All I want is for the game to detect when the player clicked a certain village. But I just can't figure it out since I'm pretty new to c# and unity. The scripts should be self-explanitory, but if you need more details please ask.