private var canPlace : boolean;
var rHitChk : IndicatorScript;
var lHitChk : IndicatorScript;
rHitChk = GetComponent(IndicatorScript);
lHitChk = GetComponent(IndicatorScript);
if((rHitChk.rHit == true lHitChk.lHit == true) || (rHitChk.rHit == false lHitChk.lHit == false))
{
print("can place = True");
canPlace = true;
return;
}
if((rHitChk.rHit == false lHitChk.lHit == true) || (rHitChk.rHit == true lHitChk.lHit == false))
{
print("can place = false");
canPlace = false;
return;
}
The above code is the section in my character that needs to reference the variable. It checks to make sure that the rays are either both hitting something (true true) or over empty space (false false).
var rHit : boolean;
var lHit : boolean;
var dist : float = 0.1;
private var hitInfoR : RaycastHit;
private var hitInfoL : RaycastHit;
if(Physics.Raycast(transform.position + Vector3(.5,-.5,0),Vector3(0,-1,0),hitInfoR,dist))
{
print("rhit = true");
rHit = true;
}
if(!Physics.Raycast(transform.position + Vector3(.5,-.5,0),Vector3(0,-1,0),hitInfoR,dist))
{
print("rhit = false");
rHit = false;
}
if(Physics.Raycast(transform.position + Vector3(-.5,-.5,0),Vector3(0,-1,0),hitInfoL,dist))
{
print("lhit = true");
lHit = true;
}
if(!Physics.Raycast(transform.position + Vector3(-.5,-.5,0),Vector3(0,-1,0),hitInfoL,dist))
{
print("lhit = false");
lHit = false;
The above code is from the Indicator’s Script. It has the rays. Trust me this part works…at least the print does. It is detecting correctly as far as I can tell from what it is printing to my console.
so as one can see, My grasp of the whole GetComponent concept is seriously lacking.
all of these exist in the Update function.