It would appear that the paddle position gets set to either my min x or max x depending on which order I have them in, instead of being clamped within the play space. I am using Unity 5.5
Here is the code I am using
namespace Block_Breaker
{
public class PaddleController : MonoBehaviour
{
// Variables - Define Paddle Control
public float paddleSpeed;
private Rigidbody2D rb2D;
private Vector2 vel;
// Use this for initialization
void Start()
{
rb2D = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
PaddleMovement();
}
void PaddleMovement()
{
Vector3 paddlePos = new Vector3(0.5f, this.transform.position.y, 0f);
float mousePosInBlocks = Input.mousePosition.x / Screen.width * 16; ;
paddlePos.x = Mathf.Clamp(mousePosInBlocks, 3.5f, -3.5f);
this.transform.position = paddlePos;
}
}
}