Question by
AylinGorgun · Jan 27, 2019 at 09:08 PM ·
mousemousepositionmouselock
Mouse movement on X axis,Mouse Stability on Y axis
Hi guys I have a game that uses the mouse movement on X axis it should be stable on the Y axis. Currently I'm using this script:
//Mouse movement X stability
float distance = transform.position.z - Camera.main.transform.position.z;
targetPos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, distance);
targetPos = Camera.main.ScreenToWorldPoint(targetPos);
Vector3 followXonly = new Vector3(targetPos.x, transform.position.y, transform.position.z);
transform.position = Vector3.Lerp (transform.position, followXonly, speed / Time.deltaTime);
It does the job but it isn't ideal it is shivering too much and very unstable is there any other way ? Oh by the way on the Start() method I need to declare a Y position by default. İt is not working with Windows dll because I'm using a mouse trail. Than 4 the help.
Comment