using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ShakeCamera : MonoBehaviour
{
private Vector3 shakePos = Vector3.zero;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
/// <summary>
/// 按住空格键,画面会一直抖动;松开按键,抖动结束
/// </summary>
void Update()
{
if(Input.GetKey(KeyCode.Space))
{
transform.localPosition -= shakePos;
shakePos = Random.insideUnitSphere / 5.0f;
transform.localPosition += shakePos;
}
}
}
unity3D 相机画面抖动的效果实现
最新推荐文章于 2024-06-25 09:32:14 发布
本文介绍了一种在Unity中实现简单相机抖动效果的方法。通过检测空格键的持续按下状态来触发相机位置的轻微随机变化,从而模拟出画面抖动的效果。此方法适用于增加游戏沉浸感。
2453

被折叠的 条评论
为什么被折叠?



