当前位置: 首页 > 工具软件 > shake > 使用案例 >

camera shake

邢飞鸿
2023-12-01
public class CameraShake : MonoBehaviour {

    // Use this for initialization
    Matrix4x4 originalProjection;
    float timer;
    void Start () 
    {
        originalProjection = camera.projectionMatrix;
        
        //StartCoroutine(Shake(0.5f));
    }
    
    // Update is called once per frame
    void Update () {
        
    }
    public void camera_Shake()
    {
        StartCoroutine(Shake(0.05f));
    }
    public IEnumerator Shake(float gap)
    {
        timer = Time.time;
        while(Time.time - timer <= gap)
        {
            Matrix4x4 p = originalProjection;
                p.m01 += Mathf.Sin(Time.time * 120F) * 0.01F;
                p.m10 += Mathf.Sin(Time.time * 150F) * 0.01F;
            camera.projectionMatrix = p;
            yield return 0;
        }
        camera.ResetProjectionMatrix();
    }
}

 

转载于:https://www.cnblogs.com/xiao-wei-wei/p/3372581.html

 类似资料:

相关阅读

相关文章

相关问答