- Home /
layermask does not exit in the context. What does this mean?
Here is my code:
using UnityEngine;
using System.Collections;
public class BlockPlaceExample : MonoBehaviour {
public GameObject terrain;
private PolygonGenerator tScript;
public GameObject target;
private LayerMask layerMaske = (1 << 0);
// Use this for initialization
void Start () {
tScript = terrain.GetComponent ("PolygonGenerator") as PolygonGenerator;
}
// Update is called once per frame
void Update () {
RaycastHit hit;
float distance = Vector3.Distance (transform.position, target.transform.position);
if( Physics.Raycast(transform.position, (target.transform.position -
transform.position).normalized, out hit, distance , layerMask)){
Debug.DrawLine (transform.position, hit.point, Color.red);
Vector2 point= new Vector2(hit.point.x, hit.point.y);
point+=(new Vector2(hit.normal.x,hit.normal.y))*-0.5f;
tScript.blocks[Mathf.RoundToInt(point.x-.5f),Mathf.RoundToInt (point.y+5f)]=0;
tScript.update=true;
} else {
Debug.DrawLine (transform.position,target.transform.position,Color.blue);
}
}
}
Here is my error: Assets/Scripts/BlockPlaceExample.cs(24,110): error CS0103: The name `layerMask' does not exist in the current context
Here is the tutorial: http://studentgamedev.blogspot.no/2013/09/unity-voxel-tutorial-part-4-destroying.html
I've already used the complete code page as a reference.
Answer by robertbu · Jan 19, 2014 at 10:43 PM
On line 9, you misspell the variable by adding an extra 'e' making it 'layerMaske' instead of 'layerMask'. When I have this error, I often copy and past variables from one reference to another to make sure they are absolutely the same.
Thank you very much!! I'll use your advice for now on.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Usage of Layer masks, what am I doing wrong? 1 Answer
Error Calling DLL function 1 Answer
DoWhile Loop is crashing Unity. Why? 2 Answers
Unity player crashes after I load Marvel Super Hero Squad? 0 Answers