Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void ApplyMovementAndRotation ()
- {
- Vector3 pos = Input.mousePosition;
- float x = -Mathf.Clamp ((Screen.width * 0.5f - pos.x) / (Screen.width * screenArea), -1f, 1f);
- float y = -Mathf.Clamp ((Screen.height * 0.5f - pos.y) / (Screen.height * screenArea), -1f, 1f);
- Vector2 vec = new Vector2 (x, y);
- float mag = vec.magnitude;
- if (mag > 1f)
- vec *= 1.0f / mag;
- mInput = Vector2.Lerp (mInput, vec, Mathf.Clamp01 (Time.deltaTime * responsiveness));
- mTurn = Vector2.Lerp (mTurn, vec - mInput, Mathf.Clamp01 (Time.deltaTime * turnSensitivity));
- mTrans.localPosition = new Vector3 (mInput.x * movementDistance.x, mInput.y * movementDistance.y, 10);
- mTrans.localRotation = Quaternion.Euler (-mTurn.y * turnDegrees.x,
- mTurn.x * turnDegrees.y,
- -mTurn.x * turnDegrees.z);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement