✅ 오늘 한 일
🎮 Project BCA
Completing main game
- 컴퓨터 green material 깜빡이기
- 머테리얼을 건드렸더니 게임이 꺼져도 그대로 유지돼서 대신 MaterialPropertyBlock 사용
- MaterialPropertyBlock을 사용할 때 Renderer에 여러 개의 머테리얼이 적용되어 있다면, 특정 머테리얼의 인덱스를 지정해서 변경해야함
using UnityEngine;
using DG.Tweening;
public class ComputerGlitter : MonoBehaviour
{
[SerializeField] private Renderer objectRenderer;
[SerializeField] private float minIntensity = 0.5f;
[SerializeField] private float maxIntensity = 1.5f;
[SerializeField] private float minDuration = 0.5f;
[SerializeField] private float maxDuration = 1.5f;
private int materialIndex = 4;
private MaterialPropertyBlock propBlock;
private Color baseColor;
void Start()
{
propBlock = new MaterialPropertyBlock();
objectRenderer.GetPropertyBlock(propBlock, materialIndex);
baseColor = objectRenderer.sharedMaterials[materialIndex].GetColor("_EmissionColor");
StartGlitterEffect();
}
void StartGlitterEffect()
{
float intensity = (Random.value > 0.5f) ? minIntensity : maxIntensity;
float duration = Random.Range(minDuration, maxDuration);
propBlock.SetColor("_EmissionColor", baseColor * intensity);
objectRenderer.SetPropertyBlock(propBlock, materialIndex);
DOVirtual.DelayedCall(duration, StartGlitterEffect);
}
}
- 버튼과 deletemode 연결
- 종 스크립트 만들기
- 마우스 커서 움직이면 중심은 체스판이지만 아주 살짝씩 움직임
- Cinemachine Camera > Rotation Control > Pan Tilt > Pan Axis, Tilt Axis 수정
- Cinemachine Input Axis Controller 추가 > Driven Axes 수정 (Accel Time 30, Decel Time 0.5)
- 종 누르면 발걸음 소리 이후 총 소리
public void PlayShooterFootstep()
{
if (currentClipIndex >= footstep_sounds.Count)
{
currentClipIndex = 0;
DOVirtual.DelayedCall(reloadDelay, PlayShooterReload);
return;
}
AudioClip clip = footstep_sounds[currentClipIndex];
audioSource.clip = clip;
audioMixer.SetFloat("ShooterVolume", footstep_volume + footstepIncrement * (currentClipIndex + 1));
audioSource.Play();
DOVirtual.DelayedCall(clip.length + gapBetweenFootsteps, PlayShooterFootstep);
currentClipIndex++;
}
private void PlayShooterReload()
{
audioMixer.SetFloat("ShooterVolume", reload_volume);
audioSource.clip = reloadSound;
audioSource.Play();
DOVirtual.DelayedCall(reloadSound.length + shotDelay, PlayShooterShot);
}
private void PlayShooterShot()
{
audioMixer.SetFloat("ShooterVolume", shot_volume);
audioSource.clip = shotSound;
audioSource.Play();
}