So im trying to link points with each other, the points that have to be linked are actual objects. At this moment i use IF and IF ELSE statements that look to the name of the point, and just some booleans for each point setting to false. Now that is not ideal because when a player places one point, i have to give it a name with a script.Maybe using a boolean array?I just want them to be able to place down linkpoints and check with my ‘‘ToolScript’’ to see what tag they have and link 2 together.
This is my script now:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
public class LinkTool : MonoBehaviour
{
//public GameObject node;
bool point1 = false;
bool point2 = false;
bool point3 = false;
float range = 10f;
//public bool[] Points = new bool[10];
//Detect if player is in range
//If in range and looking at object
//use Left mousebutton to activate Point1
//and left mousebutton to activate and link Point1 to point2
//if linked show the Indicator
GameObject hand;
// Use this for initialization
void Start()
{
}
private void Awake()
{
}
// Update is called once per frame
void Update()
{
//Do raycast that originates from the mouse clicked position,
if (Input.GetMouseButton(0))
{
RaycastHit hit;
Ray rayOrigin = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(rayOrigin, out hit, range))
{
if(hit.collider.name == "Point1")
{
point1 = true;
Debug.Log(point1);
}else if(hit.collider.name == "Point2")
{
point2 = true;
}else if(hit.collider.name == "Point3")
{
point3 = true;
}
}
}
if(point1 == true && point2 == true){
Debug.Log("Linked!");
}
}
}
Thanks in advance!