i’m experimenting with moving the paddle by using Input.getAxis(“Mouse X”) the result is a paddle the can be control even when the cursor is locked. but i’ve run into a bit of a problem limiting the horizontal movement of the padel to the left and right positions of the screen.
using UnityEngine;
public class paddle : MonoBehaviour {
public float mousePos;
// Use this for initialization
void Start () {
Cursor.lockState = CursorLockMode.Locked;
// Cursor.visible = false;
}
// Update is called once per frame
void Update () {
mousePos = transform.position.x;
if(mousePos > -9.3f || mousePos < 7.9f)
{
transform.Translate(Input.GetAxis("Mouse X") / 2, 0, 0);
}
}
}
should i assign my axis value to the mousePos variable?