摄像机震动震屏效果
using UnityEngine;using System.Collections;
public class SC_shakeCamera : MonoBehaviour
{
private float shakeTime = 0.0f;
private float fps = 20.0f;
private float frameTime = 0.0f;
private float shakeDelta = 0.005f;
public Camera cam; //= UICamera.currentCamera;
public static bool isshakeCamera = false;
// Use this for initialization
void Start()
{
//cam = UICamera.currentCamera;
shakeTime = 0.56f;
fps = 20.0f;
frameTime = 0.03f;
shakeDelta = 0.05f;
}
// Update is called once per frame
void Update()
{
if (isshakeCamera)
{
if (shakeTime > 0)
{
shakeTime -= Time.deltaTime;
if (shakeTime <= 0)
{
cam.rect = new Rect(0.0f, 0.0f, 10.0f, 10.0f);
isshakeCamera = false;
shakeTime = 0.56f;
fps = 20.0f;
frameTime = 0.03f;
shakeDelta = 0.05f;
}
else
{
frameTime += Time.deltaTime;
if (frameTime > 1.0 / fps)
{
frameTime = 0;
cam.rect = new Rect(shakeDelta * (-1.0f + 2.0f * Random.value), shakeDelta * (-1.0f + 2.0f * Random.value), 1.0f, 1.0f);
}
}
}
}
}
public static void shakeCamera()
{
isshakeCamera = true;
}
} 拉到相机上 绑定自己 做完了会出现什么效果呢?、 奥。。知道了。。但是抖动相机。。改变它的position会好一点把。。。这个的话。。。感觉不太好。。 奇怪我试了怎么没有效果呢?,已经拉到主摄像机上去了。
不错 不错 不错{:soso__3922851084632044791_6:} 感谢分享!!! 不错的效果 感谢分享·· 没用{:5_399:}{:5_399:}
页:
[1]
2