Hi,
In the block breaker section of the course when we moved the paddle left and right using our mouse we took the x value of the mouse position and normalized it with our screen width and assigned the new x value to the transform.position property of our paddle like so,
// Update is called once per frame
void Update()
{
//Normalize the current x position of the mouse w.r.t screen width
//Convert it into unity world units by multiplying it with 16 (since 4:3 aspect ratio)
Vector2 paddlePos = new Vector2(transform.position.x, transform.position.y);
//Limit the paddle's movement to be within the min and max x range
paddlePos.x = Mathf.Clamp(GetXPos(), minPaddleXValue, maxPaddleXValue);
transform.position = paddlePos;
}
private float GetXPos()
{
//If Autoplay is enabled, then change paddle position to move along with ball position
//Else move the paddle wherever the mouse moves
if (gameStatus.IsAutoPlayEnabled())
{
return ball.transform.position.x;
}
else
{
return (Input.mousePosition.x / Screen.width) * screenWidthInUnits;
}
}
In this portion of code we are not using any Time.deltaTime for the movement of our paddle. So my question is does Time.deltaTime come into play only during keyboard / joystick movement? Is it not applicable for mouse movements ?
Sorry if this question is dumb Thanks !