Hey guys! iam trying to create a building placement script but i have a weird error:
Assets/Script/BuildingPlacement.cs(30,66): error CS1525: Unexpected symbol ??', expecting
identifier’
here is the code: maybe you can have a look over it and help me out?
using UnityEngine;
using System.Collections;
public class BuildingPlacement : MonoBehaviour {
public float scrollSensitivity;
private PlaceableBuilding placeableBuilding;
private Transform currentBuilding;
private bool hasPlaced;
public LayerMask buildingsMask;
private PlaceableBuilding placeableBuildingOld;
public float speed = 30;
// Update is called once per frame
void Update () {
//Vector3 m = Input.mousePosition;
//m = new Vector3(m.x,m.y,transform.position.y);
//Vector3 p = camera.ScreenToWorldPoint(m);
if (currentBuilding != null && !hasPlaced){
//rotate object
//var speed = 30;
RaycastHit hit = new RaycastHit();
Ray ray = camera.ScreenPointToRay(Input.mousePosition);
Physics.Raycast(ray,out hit, Mathf.Infinity, groundMask);
if (Input.GetKey(KeyCode.A))
currentBuilding.transform.Rotate(Vector3.down * speed * Time.deltaTime);
//currentBuilding.position = new Vector3(p.x,0,p.z);
currentBuilding.position = hit.point;
if (Input.GetMouseButtonDown(0)) {
if (IsLegalPosition()) {
hasPlaced = true;
}
}
}
else {
if (Input.GetMouseButtonDown(0)) {
RaycastHit hit = new RaycastHit();
Ray ray = new Ray(new Vector3(p.x,8,p.z), Vector3.down);
if (Physics.Raycast(ray, out hit,Mathf.Infinity,buildingsMask)) {
if (placeableBuildingOld != null) {
placeableBuildingOld.SetSelected(false);
}
hit.collider.gameObject.GetComponent<PlaceableBuilding>().SetSelected(true);
placeableBuildingOld = hit.collider.gameObject.GetComponent<PlaceableBuilding>();
}
else {
if (placeableBuildingOld !=null) {
placeableBuildingOld.SetSelected(false);
}
}
}
}
}
bool IsLegalPosition() {
if (placeableBuilding.colliders.Count > 0) {
return false;
}
return true;
}
public void SetItem(GameObject b) {
hasPlaced = false;
currentBuilding = ((GameObject)Instantiate(b)).transform;
placeableBuilding = currentBuilding.GetComponent<PlaceableBuilding>();
}
}
thanks for any hint