Tuesday, September 15, 2015

rotate a object with mouse unity3d c#

iklan
using UnityEngine;
using System.Collections;

public class rotate : MonoBehaviour {

    public float minX = -360.0f;
    public float maxX = 360.0f;
    
    public float minY = -45.0f;
    public float maxY = 45.0f;
    
    public float sensX = 100.0f;
    public float sensY = 100.0f;
    
    float rotationY = 0.0f;
    float rotationX = 0.0f;
    
    void Update () {
        
        if (Input.GetMouseButton (0)) {
            rotationX += Input.GetAxis ("Mouse X") * sensX * Time.deltaTime;
            rotationY += Input.GetAxis ("Mouse Y") * sensY * Time.deltaTime;
            rotationY = Mathf.Clamp (rotationYminYmaxY);
            transform.localEulerAngles = new Vector3 (-rotationYrotationX0);
        }
    }
}



rotate a object with mouse unity3d c#
4/ 5
Oleh