Hey everyone, I’m quite new to Unity. I saw others posting the same issue, but I cannot relate their situation to mine: where does this code go wrong? The error is the following:
Assets/Scripts/Aiming.cs(46,28): error CS0135: `xmou’ conflicts with a declaration in a child block
and is related to the very last line of the following code:
public class Aiming : MonoBehaviour {
float xmou;
float zmou;
void Update () {
//1.calcolare posizione mouse ogni frame; 2.ruotare giocatore di x° rispetto al vettore (1,0,0)
//1.trasforma posizione mouse da pixel ad angolo rispetto a vettore (1,0,0); 2.per ogni quadrante aggiungi o sottrai gradi
//var pos = Camera.main.WorldToScreenPoint(transfor m.position);
float hei = Screen.height;
float wid = Screen.width;
float xmouabs = Input.mousePosition.x;
float zmouabs = Input.mousePosition.z;
if (xmouabs > wid/2){
var xmou = xmouabs - wid/2;
if (zmouabs > hei/2){
var zmou = zmouabs - hei/2;}
else{
var zmou = zmouabs;}
}
else if (xmouabs < wid/2){
var xmou = xmouabs;
if (zmouabs > hei/2){
var zmou = zmouabs - hei/2;}
else{
var zmou = zmouabs;}
}
Debug.Log (xmou.ToString ());