Mineable 블록에 대해 전장의 안개 추가
그림자 안나오는 문제도 해결
This commit is contained in:
33
Assets/Scripts/GameBase/FogOfWar.cs
Normal file
33
Assets/Scripts/GameBase/FogOfWar.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using UnityEngine;
|
||||
using Unity.Netcode;
|
||||
|
||||
public class FogOfWarManager : MonoBehaviour
|
||||
{
|
||||
public static FogOfWarManager Instance;
|
||||
|
||||
[Header("Settings")]
|
||||
public RenderTexture fogMaskTexture; // 쉐이더에 전달될 텍스처
|
||||
public Material fogMaterial; // 검은 안개 머티리얼
|
||||
public float revealRadius = 5f; // 밝혀지는 반경
|
||||
|
||||
void Awake() => Instance = this;
|
||||
|
||||
void Update()
|
||||
{
|
||||
// 멀티플레이어이므로 로컬 플레이어(IsOwner)의 위치만 마스크에 그립니다.
|
||||
if (NetworkManager.Singleton.LocalClient != null)
|
||||
{
|
||||
var localPlayer = NetworkManager.Singleton.LocalClient.PlayerObject;
|
||||
if (localPlayer != null)
|
||||
{
|
||||
UpdateFogMask(localPlayer.transform.position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateFogMask(Vector3 playerPos)
|
||||
{
|
||||
// 플레이어의 월드 좌표를 텍스처 좌표로 변환하여
|
||||
// 해당 지점의 알파값을 0(투명)으로 깎아내는 로직 (Compute Shader나 GPU 가속 권장)
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/GameBase/FogOfWar.cs.meta
Normal file
2
Assets/Scripts/GameBase/FogOfWar.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4867a597119adb047ab17b69beca76be
|
||||
Reference in New Issue
Block a user