- Home /
Question by
thisistheawesomestnameever · May 17, 2018 at 04:38 AM ·
rotationrotaterotate objectrotation axisrotating
Strange rotation pattern.
So I'm making a motorcycle game and when you turn I want the bike to lean but freaks out whenever you turn. I have this in my Update method:
var md = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse X"));
md = Vector2.Scale(md, new Vector2(sensitivity * smoothness, sensitivity * smoothness));
smoothV.x = Mathf.Lerp(smoothV.x, md.x, 1f / smoothness);
smoothV.y = Mathf.Lerp(smoothV.y, md.y, 1f / smoothness);
mouseLook += smoothV;
mouseLook.x = Mathf.Clamp(mouseLook.x, -45, 45);
transform.rotation = Quaternion.AngleAxis(-mouseLook.x, transform.forward);
transform.Rotate(Vector3.up, transform.rotation.z * Time.deltaTime * 7500);
transform.Translate(0, 0, 1 * speed * Time.deltaTime);
I know some of that is unnecessary, I modified an earlier script instead of making a new one.
Comment