- Home /
Question by
Radical_boy · Jul 12, 2021 at 12:43 PM ·
movement3dplayercontrol
Player Control Script Makes Movement Buggy?
So i made a script to control my Sphere Player but whenever it is in action, the Player becomes slow and barely moves at all
void Update()
{
if (Input.GetMouseButton(0))
{
if (Player.transform.position.x < 0)
return;
if (Player.transform.position.x > 20)
return;
if (PlayerPrefs.GetInt("X") == 1)
return;
d = Input.mousePosition.x;
o = ((20 * d) / Screen.width);
Player.transform.position = Vector3.Lerp(Player.transform.position, new Vector3(o, Player.transform.position.y, Player.transform.position.z), Mathf.SmoothStep(0f, 1f, 0.2f));
}
}
I don't know whats wrong with it, Can anybody help?
Comment
Answer by veyseler · Jul 12, 2021 at 03:16 PM
I am not %100 sure but Input.mousePosition is a pixel point meaning that it is a point in the screen space. Try to use this method accordingly Screen To World Point.