Help with assigning a game object in a script

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

public class battleshipsParentScript : MonoBehaviour
{
    public GameObject Ship;
    public GameObject Peg;
    public bool selctedShip;
    public bool selctedPeg;
      

    // Start is called before the first frame update
    void Start()
    {
      
    }

    // Update is called once per frame
    void OnMouseClick()
  
      
    {
        if (selctedShip == false)
        {
            Ship =
            

            selctedShip1();
        }
          
          
          
    }

    void selctedShip1()
    {
        if (selctedShip == false)
        {
            selctedShip = true;



        }
        else
        {
            selctedShip = false;

        }

    }

}

What does the ship have to equal so that when the mouse clicks on a ship,in game, that ship is assigned to the game object script? and the same for the pegs?

I don’t understand what you’re trying to accomplish. Could you try elaborating more clearly on what you want to do?

1 Like

ok so, i want to be able to click on a “ship” and then on a “peg”, so that the ship moves to the location of the peg. i was wondering how i would do this?