Visual Studio Debugging, sometimes can't see value of some local variables
I occasionally come across a locally declared variable that Visual Studio will not show a value for when I am debugging (when i mouse over it or set a watch). If I move the variable declaration outside the local scope I can then see it. Here is an example where the value of targetPos cannot be seen when stepping through the if statement even though it is in scope:
if (facingDirection == FacingDirection.Back || facingDirection == FacingDirection.Front)
{
float roundedPosX = (Mathf.Sign(transform.position.x) * (Mathf.Abs((int)transform.position.x) + 0.5f));
roundedPosX += 0.408f;
Vector3 targetPos = new Vector3(roundedPosX, transform.position.y, transform.position.z);
transform.position = Vector3.MoveTowards(transform.position, targetPos, rotateXAlignSpeed * Time.deltaTime);
}
Any ideas how to fix this or as to whats going on?
Hello, I know this is very old, but did you fix this problem? I'm experiencing it right now and I'm really struggling.
i have never seen something similar, when you use a breakpoint in for example his transform.position line you cant see targetPos value?
Good day.
Yea, somethimes i have the same issue, but i think its not a bug, its normal. Some variables need to be searched (like "GameObject.Find()") so cant see the value before it spend the resources to search it
I also have this issue from time to time. No idea what causes it.