- Home /
error CS1525: Unexpected symbol `??'
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 :)
$$anonymous$$onoDevelop throws "unexpected character '-'"
while Unity throws "Unexpected symbol ''"
both on the line Ray ray = camera.ScreenPointToRay(Input.mousePosition);
i think i dont realy know what you mean? how do i build a solution?
@Der_$$anonymous$$evin Xtro is referring to having the IDE find, and indicate all errors in either of the IDEs he mentioned have a dropDown labeled Build. in $$anonymous$$onoDevelop the command is "Build All" while in Visual Studio it is "Build Solution" this will place flags on all lines that have an error/warning, and in some cases give suggestions. for most situations Unity will give you the same exact information, but the IDE will show it to you inLine.
Answer by gardian06 · Aug 09, 2013 at 09:08 PM
drawing the text in your code block into nodePad++ it looks like there is a hidden character after the "." in "Input.mousPosition" the errors seem to go away when this is retyped.
whenever you get an error stating that there is a character in your code that you can not physically see then the best suggestion would be to draw the code into a text editor with the ability to "show all characters" takes a moment to get accustomed to it, but you will see everything.
you can also use this method to check inconsistent line endings yourself.
that was the problem. somehow there was a hidden letter in the code. but after rewriting it, everything worked. gracias!
if you could please mark the answer that helped you the most, or the most accurate answer as accepted (marking the check mark to the left of the answer)
Answer by SuryaPrakashModi · May 25, 2020 at 04:48 AM
removing that line of code and writing again may solve your problem.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Larger Than Smaller than not working 1 Answer