반응형
- 코드 작성
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#' 카테고리의 다른 글
유니티 C# 디버그 로그 종류 Debug.Log 간단 사용법 (0) | 2022.07.13 |
---|---|
유니티 C# 자주 사용하는 연산자 Operator 모음 (0) | 2022.07.13 |
유니티 C# 구글 스프레드 시트 Google Sheet 간단 사용법 (0) | 2022.07.13 |
유니티 C# 오디오 Audio Source , Audio Clip 간단 사용법 (0) | 2022.07.06 |
유니티 C# 시간 DateTime 출력하기 간단 사용법 (0) | 2022.07.06 |
유니티 C# 코루틴 Coroutine 간단 사용법 (0) | 2022.07.06 |
유니티 C# 스킬 쿨타임 구현 FillAmount 간단 사용법 (0) | 2022.07.06 |
유니티 C# 자석 효과 Magnet 간단 구현 (0) | 2022.07.06 |
댓글