Player transform.position gives incorrect values

Have a bug in my project thats cropped up out of nowhere.
When i check the playerController’s transform.position i get incorrect values back.
It appears to be clamped at -15.5 to 15.5, e.g: position of (200, 0, -80) reads correct in the inspector but in code i get (15.5, 0, -15.5)

  • Recently updated to 2021.1.1 and for some reason transform.position reads correct when Time.timeScale = 0

Maybe somethings changed with the CharacterContoller that causes this?
Anyone have any idea whats happening?

Two things that may be confusing you:

  • The inspector window in the editor shows the local position of the object. In code that would be transform.localPosition NOT transform.position. These may be different if the object has a parent.
  • If you have a CharacterController attached to your object, you generally cannot directly move the object by setting its position, as it will be overwritten by the CharacterController. You should move the object using the CharacterController’s Move method.
2 Likes