I figured it would be a nice addition to the paddle script to automate the clamp values.
Automating the Paddle’s clamp values relative to the paddle size
Hope you enjoy.
John Cordeiro
I figured it would be a nice addition to the paddle script to automate the clamp values.
Automating the Paddle’s clamp values relative to the paddle size
Hope you enjoy.
John Cordeiro
I like the idea! However, I would suggest a slightly different approach to support ingame scale changes in case people want to trigger changes in size of paddle (smaller paddle with higher levels, item-drops and such).
Might be better/more efficient ways then this, but this is how I did it:
void Update () {
float boundsSize = this.transform.lossyScale.x / 2;
mousePosInBlocks = Mathf.Clamp(((Input.mousePosition.x / Screen.width)*16),boundsSize,16f-boundsSize);
Vector3 paddlePos = new Vector3(mousePosInBlocks,this.transform.position.y,0f);
this.transform.position = paddlePos;