using UnityEngine;
using System.Collections;
public class player : MonoBehaviour {
Vector3 zhou;
float speed;
GameObject cube;
float mouse_x;
float mouse_y;
Vector3 currentMouse;
float drag = 0.2f;
float scaleFactor = 7;
void Start () {
cube=GameObject.Find("cube");
}
void Update () {
if (Input.GetMouseButton(0))
{
mouse_x = Input.GetAxis("Mouse X");
mouse_y = Input.GetAxis("Mouse Y");
currentMouse = new Vector3(mouse_x, mouse_y, 0);
zhou = Vector3.Cross(currentMouse, Vector3.forward);
speed = Vector3.Magnitude(currentMouse) * scaleFactor;
}
else {
speed = Mathf.Clamp(speed - drag, 0, Mathf.Infinity);
}
cube.transform.Rotate(zhou, speed, Space.World);
}
}
using System.Collections;
public class player : MonoBehaviour {
Vector3 zhou;
float speed;
GameObject cube;
float mouse_x;
float mouse_y;
Vector3 currentMouse;
float drag = 0.2f;
float scaleFactor = 7;
void Start () {
cube=GameObject.Find("cube");
}
void Update () {
if (Input.GetMouseButton(0))
{
mouse_x = Input.GetAxis("Mouse X");
mouse_y = Input.GetAxis("Mouse Y");
currentMouse = new Vector3(mouse_x, mouse_y, 0);
zhou = Vector3.Cross(currentMouse, Vector3.forward);
speed = Vector3.Magnitude(currentMouse) * scaleFactor;
}
else {
speed = Mathf.Clamp(speed - drag, 0, Mathf.Infinity);
}
cube.transform.Rotate(zhou, speed, Space.World);
}
}