I’ve got a code to move a paddle with keys, but i also want to be able to move the paddle with the mouse. Any tips to how to manage this?
public class Pad: MonoBehaviour {
public float moveSpeed = 15;
void Update () {
float moveInput = Input.GetAxis("Horizontal")*Time.deltaTime*moveSpeed;
transform.position += new Vector3(moveInput,0,0);
float max = 14.0f;
if(transform.position.x <= -max ||transform.position.x>=max)
{
float xPos = Mathf.Clamp(transform.position.x,-max,max);
transform.position = new Vector3(xPos,transform.position.y,transform.position.z);
}
}