资源简介
弹球 弹珠台 pinball 源代码 unity c#
代码片段和文件信息
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.AxisAngle (Vector3.up Mathf.Deg2Rad * rotationX);
Quaternion yQuaternion = Quaternion.AxisAngle (Vector3.left Mathf.Deg2Rad * rotationY);
transform.localRotation = originalRotation * xQuaternion * yQuaternion;
}
else if (axes == RotationAxes.MouseX)
{
rotationX += Input.GetAxis(“Mouse X“) * sensitivityX;
rotationX = ClampAngle (rotationX minimumX maximumX);
Quaternion xQuaternion = Quaternion.AxisAngle (Vector3.up Mathf.Deg2Rad * rotationX);
transform.localRotation = originalRotation * xQuaternion;
}
else
{
rotationY += Input.GetAxis(“Mouse Y“) * sensitivityY;
rotationY = ClampAngle (rotationY minimumY maximumY);
Quaternion yQuaternion = Quaternion.AxisAngle (Vector3.left Mathf.Deg2Rad * rotationY);
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);
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2010-02-04 19:49 Assets\
文件 4159 2010-01-22 23:59 Assets\1 skaybox.mat
文件 43888 2010-01-26 18:52 Assets\Credits1.png
目录 0 2010-01-27 20:22 Assets\Gumbi za sliper\
文件 19427 2010-01-27 13:53 Assets\Gumbi za sliper\BackButton.png
文件 18394 2010-01-26 13:34 Assets\Gumbi za sliper\CeditsButton.png
文件 19847 2010-01-26 13:34 Assets\Gumbi za sliper\ControlsButton.png
文件 61627 2010-01-27 19:00 Assets\Gumbi za sliper\creditsscreenmfinal.png
文件 20620 2009-11-22 18:36 Assets\Gumbi za sliper\logowoodgamesfx.png
目录 0 2010-01-27 20:19 Assets\Gumbi za sliper\Materials\
文件 3380 2010-01-27 20:19 Assets\Gumbi za sliper\Materials\screenpinball.mat
文件 18596 2010-01-26 13:34 Assets\Gumbi za sliper\OptionsButton.png
文件 17653 2010-01-26 13:34 Assets\Gumbi za sliper\PlayButton.png
文件 15634 2010-01-26 13:34 Assets\Gumbi za sliper\QuitButton.png
文件 18202 2010-01-27 13:53 Assets\Gumbi za sliper\ReturnButton.png
文件 496980 2010-01-26 13:34 Assets\Gumbi za sliper\ScreenPinball.jpg
文件 292202 2010-01-27 13:53 Assets\Gumbi za sliper\ScreenPinballOptions 1.jpg
文件 292202 2010-01-27 13:53 Assets\Gumbi za sliper\ScreenPinballOptions.jpg
文件 184348 2010-01-26 13:34 Assets\Gumbi za sliper\ScreenPinbButtonscopy.jpg
文件 26624 2010-01-26 13:35 Assets\Gumbi za sliper\Thumbs.db
文件 18666 2009-11-23 22:07 Assets\hst_stingray_nebula.jpg
文件 20620 2009-11-22 18:36 Assets\logowoodgamesfx.png
目录 0 2010-01-27 19:29 Assets\Materials\
文件 3349 2010-01-27 19:29 Assets\Materials\controller.mat
文件 3557 2010-01-27 19:29 Assets\Materials\loadingdoor.mat
文件 3418 2010-01-27 19:29 Assets\Materials\machinegun.mat
文件 3395 2010-01-27 19:29 Assets\Materials\muzzleflash.mat
文件 3309 2009-10-28 17:09 Assets\Materials\Orange.mat
文件 3498 2010-01-25 17:47 Assets\Materials\planepodlogalamps 1.mat
文件 3368 2010-01-25 18:05 Assets\Materials\planepodlogalamps.mat
文件 3269 2010-01-25 17:47 Assets\Materials\podloga-plane.mat
............此处省略1145个文件信息
评论
共有 条评论