资源简介
e8c6b634c3299ade5946c7e2fb9c1d21.rar
代码片段和文件信息
using UnityEngine;
using System.Collections;
/// MouseLook rotates the transform based on the mouse delta.
/// Minimum and Maximum values can be used to constrain the possible rotation
/// To make an FPS style character:
/// - Create a capsule.
/// - Add a rigid body to the capsule
/// - Add the MouseLook script to the capsule.
/// -> Set the mouse look to use LookX. (You want to only turn character but not tilt it)
/// - Add FPSWalker script to the capsule
/// - Create a camera. Make the camera a child of the capsule. Reset it‘s transform.
/// - Add a MouseLook script to the camera.
/// -> Set the mouse look to use LookY. (You want the camera to tilt up and down like a head. The character already turns.)
[AddComponentMenu(“Camera-Control/Mouse Look“)]
public class MouseLook : MonoBehaviour {
public enum RotationAxes { MouseXAndY = 0 MouseX = 1 MouseY = 2 }
public RotationAxes axes = RotationAxes.MouseXAndY;
public float sensitivityX = 15F;
public float sensitivityY = 15F;
public float minimumX = -360F;
public float maximumX = 360F;
public float minimumY = -60F;
public float maximumY = 60F;
float rotationX = 0F;
float rotationY = 0F;
Quaternion originalRotation;
void Update ()
{
if (axes == RotationAxes.MouseXAndY)
{
// Read the mouse input axis
rotationX += Input.GetAxis(“Mouse X“) * sensitivityX;
rotationY += Input.GetAxis(“Mouse Y“) * sensitivityY;
rotationX = ClampAngle (rotationX minimumX maximumX);
rotationY = ClampAngle (rotationY minimumY maximumY);
Quaternion xQuaternion = Quaternion.AngleAxis (rotationX Vector3.up);
Quaternion yQuaternion = Quaternion.AngleAxis (rotationY Vector3.left);
transform.localRotation = originalRotation * xQuaternion * yQuaternion;
}
else if (axes == RotationAxes.MouseX)
{
rotationX += Input.GetAxis(“Mouse X“) * sensitivityX;
rotationX = ClampAngle (rotationX minimumX maximumX);
Quaternion xQuaternion = Quaternion.AngleAxis (rotationX Vector3.up);
transform.localRotation = originalRotation * xQuaternion;
}
else
{
rotationY += Input.GetAxis(“Mouse Y“) * sensitivityY;
rotationY = ClampAngle (rotationY minimumY maximumY);
Quaternion yQuaternion = Quaternion.AngleAxis (rotationY Vector3.left);
transform.localRotation = originalRotation * yQuaternion;
}
}
void Start ()
{
// Make the rigid body not change rotation
if (rigidbody)
rigidbody.freezeRotation = true;
originalRotation = transform.localRotation;
}
public static float ClampAngle (float angle float min float max)
{
if (angle < -360F)
angle += 360F;
if (angle > 360F)
angle -= 360F;
return Mathf.Clamp (angle min max);
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
I.A.... 3357 2010-04-28 21:24 test1\Assets\img\Materials\zhuanqiang.mat
文件 806466 2010-04-28 17:36 test1\Assets\img\micai.bmp
文件 883854 2010-04-28 17:36 test1\Assets\img\zhuanqiang.BMP
文件 72681 2010-04-28 17:35 test1\Assets\Level\test1.unity
I.A.... 105725 2010-04-29 08:23 test1\Assets\Level\test2.unity
文件 12697 2010-04-28 17:35 test1\Assets\Level\test_menu.unity
I.A.... 3352 2010-04-28 20:47 test1\Assets\Materials\micai 1.mat
I.A.... 3352 2010-04-28 20:47 test1\Assets\Materials\micai 2.mat
I.A.... 3352 2010-04-28 20:47 test1\Assets\Materials\micai 3.mat
文件 3646 2010-04-28 17:35 test1\Assets\Materials\micai.mat
I.A.... 3357 2010-04-28 20:47 test1\Assets\Materials\zhuanqiang.mat
I.A.... 2473626 2010-04-28 21:24 test1\Assets\New Terrain 1.asset
I.A.... 2473628 2010-04-28 21:24 test1\Assets\New Terrain.asset
I.A.... 17987 2010-04-28 20:47 test1\Assets\Prefabs\Bullet.prefab
I.A.... 18712 2010-04-28 20:47 test1\Assets\Prefabs\Tank01.prefab
I.A.... 8114 2010-04-28 20:47 test1\Assets\Prefabs\Wall.prefab
文件 126 2010-04-28 17:35 test1\Assets\sc
文件 625 2010-04-28 17:35 test1\Assets\sc
文件 483 2010-04-28 17:35 test1\Assets\sc
文件 713 2010-04-28 17:35 test1\Assets\sc
I.A.... 5664 2010-04-28 20:47 test1\Assets\Standard Assets\Blob-Shadow\blob shadow projector.prefab
文件 22526 2010-04-28 17:35 test1\Assets\Standard Assets\Blob-Shadow\Falloff.psd
文件 4676 2010-04-28 17:35 test1\Assets\Standard Assets\Blob-Shadow\shadow material.mat
文件 140326 2010-04-28 17:35 test1\Assets\Standard Assets\Blob-Shadow\Shadow.psd
文件 596 2010-04-28 17:35 test1\Assets\Standard Assets\Blob-Shadow\ShadowProjection.shader
文件 2705 2010-04-28 17:35 test1\Assets\Standard Assets\Camera sc
文件 1046 2010-04-28 17:35 test1\Assets\Standard Assets\Camera sc
文件 1873 2010-04-28 17:35 test1\Assets\Standard Assets\Camera sc
文件 591 2010-04-28 17:35 test1\Assets\Standard Assets\Camera sc
文件 385906 2010-04-28 17:35 test1\Assets\Standard Assets\Fonts\Courier.dfont
............此处省略600个文件信息
相关资源
- VirtualBreadboard4.3.8.msi
- zw_温湿度信号采集控制系统V1.0.zip
- phrack.zip
- tesseract4.0-vs2015-64.zip
- DeepLearninginNaturalLanguageProcessing.pdf
- HiTool-STB-5.0.27.rar
- 三菱PLCQD77MS定位模块PLC运动控制视频
- 电路基础原书第5版.pdf
- 《SpringBoot+Vue全栈开发实战》王松.p
- Simulate-3.2.zip
- TLVAnalysis.rar
- upload_new.rar
- tsingcheng_liu_10687796.zip
- TMS320DSP算法标准.pdf
- 声学仿真计算从入门到精通--西北工业
- ABAQUSExplicit有限元软件入门指南.pdf
- R语言数据挖掘方法及应用薛薇2016-完
- tx6816_v20泰和安TX6816消防控制室图形监
- OrCAD9.2pSpice9.2完全版.rar
- Music.zip176814
- 在线心理健康分析系统v1.4.zip
- 45款银行字体2020版.zip
- Location虚拟定位(10.0-12.4版本).rar
- JetbrainsCrack-2.6.2.tar.gz
- 18731.rar
- 恒生基金投资管理系统O3.2用户手册(
- 10.1-17.10.zip
- 书籍.zip
- 最新牛牛源码三公炸金花牌九二八杠
- WiFi破解字典.rar
评论
共有 条评论