본문 바로가기
개발/C#

유니티 C# 카메라 흔들기 Camera Shake 간단 사용법

by SPNK 2022. 7. 6.
반응형
  • 코드 작성
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Example : MonoBehaviour
{
    public float shakeAmount = 3.0f;
    public float shakeTime = 1.0f;

    private void Start()
    {
        StartCoroutine(Shake(shakeAmount, shakeTime));
    }

    IEnumerator Shake(float ShakeAmount, float ShakeTime)
    {
        float timer = 0;
        while (timer <= ShakeTime)
        {
            Camera.main.transform.position = 
                (Vector3)UnityEngine.Random.insideUnitCircle * ShakeAmount;
            timer += Time.deltaTime;
            yield return null;
        }
        Camera.main.transform.position = new Vector3(0f, 0f, 0f);
    }
}

참고할만한 글

 

 

유니티 C# 오디오 Audio Source , Audio Clip 간단 사용법

코드 작성 using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Example : MonoBehaviour { public AudioSource audioSource; public AudioClip audioClip; private void Start() { audio

parksh3641.tistory.com

 

 

 

유니티 C# 구글 스프레드 시트 Google Sheet 간단 사용법

코드 작성 using System.Collections; using System.Collections.Generic; using System.IO; using UnityEngine; using UnityEngine.Networking; public class Example : MonoBehaviour { const string DownloadURL = "https://docs.google.com/spreadsheets/d/" + "주

parksh3641.tistory.com

 

반응형

댓글