So in my script I am using Raycast to identify an object when clicked. So far it detects objects with a tag of “Card” (I have some more code in it but it doesn’t affect it yet) what I want it to do is to assign said object as a variable called Card for later use.
Here’s the code:
#pragma strict
var Tile : GameObject;
var Check : boolean = false;
var Card : GameObject;
function Update(){
if(Input.GetMouseButton(0)){
var hit : RaycastHit;
var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if(Physics.Raycast(ray,hit)){
if(hit.collider.tag == "Card"){
Debug.Log(hit.collider.name);
Check = true;
Card == Object;
}
}
}
Now how can I use the Raycast to take an object Tagged “Card” and assign that GameObject to the Var Card.