feat: 투사체 발사 스킬 구현

- SkillProjectile: 서버 권위 이동/충돌, caster 자식 콜라이더 충돌 무시 추가
- SpawnEffect: hitEffect 필드 추가 (투사체 명중 시 적용할 효과 분리)
- SkillEffect: Team 컴포넌트 없는 환경 오브젝트 타겟 제외 처리
- Prefab_Skill_ProjectileBasic 프리팹 생성 (NetworkObject + NetworkTransform + Rigidbody + SphereCollider)
- 투사체 스킬 에셋 추가 (SkillData, SpawnEffect, DamageEffect)
- Anim_Common_찌르기 애니메이션 이벤트 추가 (OnEffect @ 0.867s, OnSkillEnd @ 1.3s)
- DefaultNetworkPrefabs에 Prefab_Skill_ProjectileBasic 등록

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-18 15:51:41 +09:00
parent f73a2ca9d7
commit a9aa3a3091
16 changed files with 2626 additions and 18 deletions

View File

@@ -1,4 +1,5 @@
using UnityEngine;
using Unity.Netcode;
namespace Colosseum.Skills.Effects
{
@@ -15,26 +16,42 @@ namespace Colosseum.Skills.Effects
[SerializeField] private bool parentToCaster = false;
[Min(0f)] [SerializeField] private float autoDestroyTime = 3f;
[Header("Hit Settings")]
[Tooltip("투사체가 대상에 명중했을 때 적용할 효과. 미설정 시 명중 효과 없음.")]
[SerializeField] private SkillEffect hitEffect;
protected override void ApplyEffect(GameObject caster, GameObject target)
{
if (prefab == null || caster == null) return;
Vector3 spawnPos = GetSpawnPosition(caster, target) + spawnOffset;
Quaternion spawnRot = GetSpawnRotation(caster, target);
Transform parent = parentToCaster ? caster.transform : null;
GameObject instance = Object.Instantiate(prefab, spawnPos, spawnRot, parent);
// SkillProjectile 컴포넌트가 있으면 초기화
var projectile = instance.GetComponent<SkillProjectile>();
if (projectile != null)
var networkObject = prefab.GetComponent<NetworkObject>();
if (networkObject != null)
{
projectile.Initialize(caster, this);
// 네트워크 오브젝트: 서버에서 스폰 후 전파
// (OnEffect 가드에 의해 이미 서버에서만 호출됨)
GameObject instance = Object.Instantiate(prefab, spawnPos, spawnRot);
var spawnedNet = instance.GetComponent<NetworkObject>();
spawnedNet.Spawn(destroyWithScene: true);
var projectile = instance.GetComponent<SkillProjectile>();
if (projectile != null)
projectile.Initialize(caster, hitEffect);
}
if (autoDestroyTime > 0f)
else
{
Object.Destroy(instance, autoDestroyTime);
// 로컬 오브젝트 (파티클 등): 기존 방식 유지
Transform parent = parentToCaster ? caster.transform : null;
GameObject instance = Object.Instantiate(prefab, spawnPos, spawnRot, parent);
var projectile = instance.GetComponent<SkillProjectile>();
if (projectile != null)
projectile.Initialize(caster, hitEffect);
if (autoDestroyTime > 0f)
Object.Destroy(instance, autoDestroyTime);
}
}

View File

@@ -93,6 +93,9 @@ namespace Colosseum.Skills
private bool IsCorrectTeam(GameObject caster, GameObject target)
{
// Team 컴포넌트가 없는 오브젝트(환경, 바닥, 벽 등)는 타겟 제외
if (target.GetComponent<Team>() == null) return false;
bool isSameTeam = Team.IsSameTeam(caster, target);
return targetTeam switch

View File

@@ -1,12 +1,14 @@
using UnityEngine;
using Unity.Netcode;
namespace Colosseum.Skills
{
/// <summary>
/// 스킬 투사체. 충돌 시 연결된 효과를 적용합니다.
/// 서버에서만 이동/충돌을 처리하며, NetworkTransform으로 위치를 동기화합니다.
/// </summary>
[RequireComponent(typeof(Rigidbody))]
public class SkillProjectile : MonoBehaviour
public class SkillProjectile : NetworkBehaviour
{
[Header("이동 설정")]
[Min(0f)] [SerializeField] private float speed = 15f;
@@ -41,29 +43,39 @@ namespace Colosseum.Skills
rb.useGravity = false;
rb.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
}
// caster 및 자식 콜라이더와의 충돌 무시
var myColliders = GetComponents<Collider>();
foreach (var cc in caster.GetComponentsInChildren<Collider>())
foreach (var mc in myColliders)
Physics.IgnoreCollision(mc, cc);
}
private void Start()
{
Destroy(gameObject, lifetime);
// 서버에서만 수명 관리
if (IsServer)
Invoke(nameof(ServerDespawn), lifetime);
}
private void FixedUpdate()
{
if (!initialized || rb == null) return;
// 서버에서만 이동 처리
if (!IsServer || !initialized || rb == null) return;
rb.linearVelocity = transform.forward * speed;
}
private void OnTriggerEnter(Collider other)
{
if (!initialized || sourceEffect == null) return;
// 서버에서만 충돌 처리
if (!IsServer || !initialized || sourceEffect == null) return;
if (other.gameObject == caster) return;
// 유효한 타겟인지 확인
if (!sourceEffect.IsValidTarget(caster, other.gameObject))
return;
// 충돌 이펙트
// 충돌 이펙트 (서버에서 스폰 → 클라이언트에도 표시되려면 NetworkObject여야 함)
if (hitEffect != null)
{
var effect = Instantiate(hitEffect, transform.position, transform.rotation);
@@ -77,10 +89,16 @@ namespace Colosseum.Skills
if (!penetrate || penetrationCount >= maxPenetration)
{
Destroy(gameObject);
ServerDespawn();
}
}
private void ServerDespawn()
{
if (!IsServer || !IsSpawned) return;
NetworkObject.Despawn(true);
}
public void SetDirection(Vector3 direction)
{
transform.rotation = Quaternion.LookRotation(direction.normalized);