Quantcast
Channel: Questions in topic: "isolate"
Viewing all articles
Browse latest Browse all 10

Mouse click to select and Isolate

$
0
0
Hi- I need some help determining the right way to isolate an object after its selected. So far I have been able to set tags for each gameobject, and I have a selection created that reads the part selected once its clicked with the left mouse bottom as you can see below. Looking for online answers, I noticed that one way is to enable/disable the other gameobjects once one is selected. The other way I saw was to hide/unhide. Can someone tell me whats the best way to accomplish this. Thanks using System.Collections; public class Selection : MonoBehaviour { Ray ray; RaycastHit hit; void Start () { } void Update () { selection(); } void selection () { // Use Input.GetKeyDown() for single clicks if(Input.GetKeyDown(KeyCode.Mouse0) ) { // Reset ray with new mouse position25. ray = Camera.main.ScreenPointToRay(Input.mousePosition); if(Physics.Raycast(ray, out hit)) { //hit.transform.tag used to refer to especific object tag name if(hit.transform.tag == "Leftdoor") { } if(hit.transform.tag == "Rightdoor") { } if(hit.transform.tag == "Trunkdoor") { } if(hit.transform.tag == "hood") { } if (hit.transform.tag == "Untagged") { } Debug.Log("You have selected: " + hit.transform.tag); } } } }

Viewing all articles
Browse latest Browse all 10

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>