Question by 
               soakes95 · Aug 09, 2017 at 04:12 PM · 
                c#camerascripting problemscreentoworldpoint  
              
 
              ScreenToWorldPoint not working
Hi, so im getting this error and i don't know why please help!
Assets/Script/BuildingPlacement.cs(23,23): error CS1061: Type UnityEngine.Component' does not contain a definition for ScreenToWorldPoint' and no extension method ScreenToWorldPoint' of type UnityEngine.Component' could be found. Are you missing an assembly reference?
 private PlaceableBuilding placealeBuilding;
 private Transform currentBuilding;
 private bool hasPlaced;
 // Use this for initialization
 void Start () {
     
 }
 
 // Update is called once per frame
 void Update () 
 {
     if (currentBuilding != null && !hasPlaced) 
     {
         Vector3 m = Input.mousePosition;
         m = new Vector3 (m.x, m.y, transform.position.y);
         Vector3 p = camera.ScreenToWorldPoint(m);
         currentBuilding.position = new Vector3 (p.x,0,p.z);
         if (Input.GetMouseButtonDown (0)) 
         {
             if (IsLegalPosition ()) {
                 hasPlaced = true;
             }
         }
     }
 }
 bool IsLegalPosition()
 {
     if (placealeBuilding.colliders.Count > 0) 
     {
         return false;
     }
     return true;
 }
 public void SetItem(GameObject b)
 {
     hasPlaced = false;
     currentBuilding = ((GameObject)Instantiate (b)).transform;
     placealeBuilding = currentBuilding.GetComponent<PlaceableBuilding> ();
 }
 
               }
               Comment
              
 
               
              Answer by soakes95 · Aug 10, 2017 at 02:11 PM
Problem Solved, i changed Vector3 p = camera.ScreenToWorldPoint(m); to Vector3 p = camera.main.ScreenToWorldPoint(m);
Your answer