private void CheckLimits(Vector3 posAtual) { SpriteRenderer renderer = GetComponent<SpriteRenderer>(); float newX = Mathf.Clamp(transform.position.x, cam.ScreenToWorldPoint(new Vector3(0, 0, 0)).x + renderer.bounds.size.x/2, cam.ScreenToWorldPoint(new Vector3(cam.pixelWidth, 0, 0)).x - renderer.bounds.size.x / 2); transform.position = new Vector3(newX, posAtual.y, posAtual.z); }
Nenhum comentário:
Postar um comentário