OK, this error has been bugging me for some time now, and I just can't figure it out. Please someone point out the error to me, because as far as I know, my code is correct. I added an extra if statement to check for an objects tag, and suddenly, the code which worked before throws up an error message - not even the new code itself!
The code previously parented a raycast hit object to the controlled object and allowed you to move it around. I am trying to check for tags to see if an object is moveable, or if it is a switch.
Heres the code. I've put in a note where the error occurs, and another note where the newly entered code in. All help is appreciated!
var hasObject: boolean = false;
var otherThing: Transform;
function Update () {
var fwd = Camera.main.transform.forward;
var hit : RaycastHit;
var LayerMask = (1<<9) | (1<<10);
Debug.DrawRay(camera.main.transform.position, (transform.position-camera.main.transform.position) * 50, Color.red);
If (Input.GetButtonDown ("Fire2"))
{
if (!hasObject)
{
if (Physics.Raycast(camera.main.transform.position, (transform.position-camera.main.transform.position), hit, 75, LayerMask))
{
otherThing = hit.transform;
//The next line is the new line of code which is causing the error.
if (otherThing.tag("Moveable"));
{
//The line below is where the error is being thrown up.
otherThing.rigidbody.isKinematic = true;
otherThing.rigidbody.detectCollisions = false;
otherThing.transform.position.z = 0;
otherThing.parent = transform;
otherThing.Find("Glowblock").light.enabled = true;
hasObject = true;
//This next section is also new.
}else if
{
(otherThing.tag("switchable"));
Debug.Log ("This is a switch");
}
}
}else
{
otherThing.rigidbody.isKinematic = false;
otherThing.rigidbody.detectCollisions = true;
transform.DetachChildren();
otherThing.transform.position.z = 0;
otherThing.Find("Glowblock").light.enabled = false;
hasObject = false;
}
}
}