Priv's Blog

Programming Simple Functionality: Unit 3 - Sound and Effects) Lesson 3.4 - Particles and Sound Effects 본문

Unity Learn/Pathway: Junior Programmer

Programming Simple Functionality: Unit 3 - Sound and Effects) Lesson 3.4 - Particles and Sound Effects

Priv 2021. 7. 24. 18:07

출처

 

Lesson 3.4 - Particles and Sound Effects - Unity Learn

Overview: This game is looking extremely good, but it’s missing something critical: Sound effects and Particle effects! Sounds and music will breathe life into an otherwise silent game world, and particles will make the player’s actions more dynamic an

learn.unity.com


 

 

1. 서언


(영상: 링크 참조)

 

Lesson 3.4 - Particles and Sound Effects - Unity Learn

Overview: This game is looking extremely good, but it’s missing something critical: Sound effects and Particle effects! Sounds and music will breathe life into an otherwise silent game world, and particles will make the player’s actions more dynamic an

learn.unity.com


 

 


 

2. 폭발 파티클 커스터마이즈 하기

첫 번째로 여러분이 추가해야 하는 파티클 효과는 플레이어가 장애물에 충돌했을 때 폭발하는 효과입니다.

 


(영상: 링크 참조)

 

Lesson 3.4 - Particles and Sound Effects - Unity Learn

Overview: This game is looking extremely good, but it’s missing something critical: Sound effects and Particle effects! Sounds and music will breathe life into an otherwise silent game world, and particles will make the player’s actions more dynamic an

learn.unity.com


 

  1. Course 라이브러리 > Particles에서 FX_Explosion_Smoke를 hierarchy 안으로 드래그하시고, Play / Restart / Stop 버튼을 사용해 미리 보기 해주세요.
  2. 여러분의 파티클 시스템을 여러분이 원하는 데로 다룰 수 있도록 세팅들을 자유롭게 만져보세요.
  3. Play on Awake 설정을 설정 해제해주세요.
  4. 파티클을 여러분의 플레이어에 드래그하셔서 자식 오브젝트로 만들어주신 뒤, 플레이어를 기준으로 위치를 잡아주세요.

 


 

3. 충돌 시 파티클 재생하기

파티클 이팩트와 충돌에 의한 폭발을 발견했으나, Player Controller에 이를 할당하고, 재생을 위한 새로운 코드를 작성해야 합니다.

 


(영상: 링크 참조)

 

Lesson 3.4 - Particles and Sound Effects - Unity Learn

Overview: This game is looking extremely good, but it’s missing something critical: Sound effects and Particle effects! Sounds and music will breathe life into an otherwise silent game world, and particles will make the player’s actions more dynamic an

learn.unity.com


 

  1. PlayerController.cs 안에서 새로운 public ParticleSystem explosionParticle;을 선언해주세요.
  2. Inspector 안에서 explosionexplosion particle 변수에 할당해주세요.
  3. 플레이어가 장애물과 충돌하는 if문 안에서 explosionParticle.Play();를 호출하시고, 파티클 프로퍼티(particle properties)를 조정 및 테스트해주세요.

 

 


 

4. 흙먼지를 흩뿌리는 파티클 효과 추가하기

다음으로 여러분은 흙먼지를 흩뿌리는 파티클 효과를 추가하여 플레이어가 scene을 달려 나갈 때, 땅을 박차고 나가는 듯이 보이도록 만들어주어야 합니다. 한 가지 트릭은 플레이어가 땅 위에 있을 때만 파티클이 재생되어야 한다는 것입니다.

 


(영상: 링크 참조)

 

Lesson 3.4 - Particles and Sound Effects - Unity Learn

Overview: This game is looking extremely good, but it’s missing something critical: Sound effects and Particle effects! Sounds and music will breathe life into an otherwise silent game world, and particles will make the player’s actions more dynamic an

learn.unity.com


 

  1. Fx_DirtSplatter를 Player의 자식 오브젝트로 드래그하시고, 위치 값, 회전 값 및 설정들을 편집해주세요.
  2. 새로 public ParticleSystem dirtParticle;를 선언하시고, Inspector 안에 할당해주세요.
  3.  플레이어가 장애물을 뛰어넘거나 장애물과 충돌했을 때 dirtParticle.Stop();를 추가해주세요.
  4. 플레이어가 땅(ground)에 있을 때 dirtParticle.Play();를 추가해주세요.

 

 


 

5. 카메라 오브젝트에 음악 추가하기

여러분의 파티클 이팩트가 보기 좋게 완성되었으니, 이제 사운드로 넘어갈 차례입니다! 음악을 추가하기 위해서는, 카메라에 sound 컴포넌트를 추가해주어야 합니다. 작업이 끝나면, 카메라가 scene의 눈과 귀가 되어줄 것입니다.

 


(영상: 링크 참조)

 

Lesson 3.4 - Particles and Sound Effects - Unity Learn

Overview: This game is looking extremely good, but it’s missing something critical: Sound effects and Particle effects! Sounds and music will breathe life into an otherwise silent game world, and particles will make the player’s actions more dynamic an

learn.unity.com


 

  1. Main 카메라 오브젝트를 선택하시고, Add Component > Audio Source로 가주세요.
  2. Course Library > Sound에서, music clip을 inspector 안에 있는 AudioClip 변수로 드래그해주세요.
  3. 볼륨을 줄여서 사운드 이팩트가 더 쉽게 들릴 수 있도록 만들어주세요.
  4. Loop 체크박스를 클릭해주세요.

 


 

6. 오디오 클립(Audio Clips)을 위한 변수 선언하기

이제 멋진 음악이 재생되고 있으니, 사운드 이팩트를 추가할 차례입니다. 이번에는 오디오 클립(Audoi Clips)이 카메라 자체가 아닌, 플레이어에서 나올 것입니다.

 


(영상: 링크 참조)

 

Lesson 3.4 - Particles and Sound Effects - Unity Learn

Overview: This game is looking extremely good, but it’s missing something critical: Sound effects and Particle effects! Sounds and music will breathe life into an otherwise silent game world, and particles will make the player’s actions more dynamic an

learn.unity.com


 

  1. PlayerController.cs 안에서 새로 public AudioClip jumpSound;public AudioClip crashSound;를 선언해주세요.
  2. Course Library > Sound에서 클립을 새로운 inspector 안의 sound 변수로 드래그해주세요.

 


 

7. 점프 및 충돌 시 오디오 클립 재생하기

PlayerController에 점프 및 충돌에 대한 오디오 클립을 할당했습니다. 이제 제시간에 오디오를 재생시켜 여러분의 게임에 완전한 오디오 경험을 제공할 차례입니다.

 


(영상: 링크 참조)

 

Lesson 3.4 - Particles and Sound Effects - Unity Learn

Overview: This game is looking extremely good, but it’s missing something critical: Sound effects and Particle effects! Sounds and music will breathe life into an otherwise silent game world, and particles will make the player’s actions more dynamic an

learn.unity.com


 

  1. Audio Source 컴포넌트를 player에 추가해주세요.
  2. 새로 private AudioSource playerAudio;를 선언하고, playerAudio = GetComponent<AudioSource>();로 초기화해주세요.
  3. playerAudio.PlayOneShot(jumpSound, 1.0f);가 캐릭터가 점프할 때 호출되도록 만들어주세요.
  4. playerAudio.PlayerOneShot(crahSound, 1.0f);가 캐릭터가 충돌할 때 호출되도록 만들어주세요.

 

 

 


 

8. 내용 복습


(영상: 링크 참조)

 

Lesson 3.4 - Particles and Sound Effects - Unity Learn

Overview: This game is looking extremely good, but it’s missing something critical: Sound effects and Particle effects! Sounds and music will breathe life into an otherwise silent game world, and particles will make the player’s actions more dynamic an

learn.unity.com


 

- 새로 배운 기능들

  • 게임이 진행되는 동안 음악 재생하기
  • 플레이어가 달리고 있을 때 파티클 이팩트 재생하기
  • 플레이어가 장애물과 부딪힐 때, 폭발 및 음향 효과 재생하기

 

- 새로 배운 개념과 기술들

  • 파티클 시스템
  • 자식 오브젝트 포지셔닝
  • 오디오 클립(Audio clips)과 오디오 소스(Audio sources)
  • 사운드 이팩트 실행과 중단

 

- 전체 요약

  • 여러분은 매우 세련된 게임을 완성하셨습니다. - 정말 멋진 사운드와 파티클 이팩트가 들어 있고, 경쾌한 배경 음악도 있습니다. 여러분의 캐릭터들을 위한 애니메이션을 어떻게 활용하는 지를 배웠으며, 배경화면이 무한대로 스크롤되도록 만드는 프로그래밍 마법도 부려 보았습니다.

 


 


수고하셨습니다!


Comments