36 lines
		
	
	
		
			961 B
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			961 B
		
	
	
	
		
			C#
		
	
	
	
using System.Collections;
 | 
						|
using System.Collections.Generic;
 | 
						|
using UnityEngine;
 | 
						|
 | 
						|
public class CameraMove : MonoBehaviour
 | 
						|
{
 | 
						|
    public float speed = 5.0f;
 | 
						|
    public float speed_rotate = 60.0f;
 | 
						|
    // Use this for initialization
 | 
						|
    void Start()
 | 
						|
    {
 | 
						|
 | 
						|
 | 
						|
    }
 | 
						|
 | 
						|
    // Update is called once per frame
 | 
						|
    void Update()
 | 
						|
    {
 | 
						|
        float x = Input.GetAxis("Horizontal") * Time.deltaTime * speed;
 | 
						|
        float z = Input.GetAxis("Vertical") * Time.deltaTime * speed;
 | 
						|
 | 
						|
        transform.Translate(x, 0, z);
 | 
						|
        float a = Input.GetAxis("Mouse X") * Time.deltaTime * speed_rotate;
 | 
						|
        float b = Input.GetAxis("Mouse Y") * Time.deltaTime * speed_rotate;
 | 
						|
        if (Input.GetMouseButton(1))
 | 
						|
        {
 | 
						|
            print("a:" + a + ";b:" + b);
 | 
						|
            transform.Rotate(-b, a, 0);
 | 
						|
            transform.eulerAngles = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, 0);
 | 
						|
            //transform.Rotate(b, 0, 0, Space.Self);
 | 
						|
        }
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    }
 | 
						|
} |