Home > Back-end >  The use of c # if statements within the assignment can't
The use of c # if statements within the assignment can't

Time:11-22

See xA, xB, think if run after used for operation, display "in the use of not assignment of the local variable", cannot operation, if began to define an initial value to xA=xB=0, the final result xStep will only equal to zero and experience to calculate both the if statement is carried out, but the statement within assigned the value of the statement, there is no outside,
To solve, thank you, the purpose is to get two if xB - the result of the xA,

Vector2 touchPosition=Input. MousePosition;
Bool isStillOn=false;
Float xA, yA, tA, xB, yB, tB;


If (Input. GetMouseButtonDown (0) & amp; & IsStillOn==false)
{
XA=touchPosition. X;
YA=touchPosition. Y;
TA=Time. DeltaTime;
IsStillOn=true;
The Debug Log (tA); The Debug Log (yA); The Debug Log (xA);
}

If (Input. GetMouseButtonUp (0))
{
XB=touchPosition. X;
YB=touchPosition. Y;
TB=Time. DeltaTime;
IsStillOn=false;
The Debug Log (tB); The Debug Log (yB); The Debug Log (xB);
}

Float xStep=(xB - xA)/10;
  • Related