Unity/Asset 분석
[RTS Engine] 공격에 반응하지 않게 하기 & 반응 후 처리
lipnus
2022. 6. 18. 19:18
반응형
다른 짓은 해도 소용없고..
1. 다른 유닛이 아예 타겟에 잡히지 않도록 하기
1번과정을 해도, 전체적인 AI 시스템에 의해서 유닛전체가 특정 명령을 받게 된다.
2. 복귀 지점 코드
NPCDefenceManager.cs
/// <summary>
/// Sends units back to their creator buildings if it exists, else send them back to their capital building or initial faction start position.
/// </summary>
/// <param name="units">IEnumerable instance of Unit instances to send back.</param>
public void SendBackUnits (IEnumerable<Unit> units)
{
//go through the units:
foreach(Unit u in units)
//if the unit is valid:
if(u != null)
{
//make each unit go back to its creator building if it exists, else the faction capital
Building targetBuilding = u.Creator ? u.Creator : gameMgr.GetFaction(factionMgr.FactionID).CapitalBuilding;
//send unit back (it there's no capital building, send to initial camera look at position):
gameMgr.MvtMgr.Move(u,
targetBuilding
? (targetBuilding.RallyPoint ? targetBuilding.RallyPoint.transform.position : targetBuilding.transform.position)
: gameMgr.GetFaction(factionMgr.FactionID).GetCamLookAtPosition(),
targetBuilding ? targetBuilding.GetRadius() : 0.0f, targetBuilding, InputMode.building, false);
}
}
위 코드를 통해 시작건물 또는 초기 카메라 위치로 이동
본 게임의 경우 건물은 사용하지 않음
그래서 EnemySpawner의 Destination을 초기 카메라 위치로 설정해놓으면
궁극적으로 거기로 이동하게 되므로 본 게임의 목적에 맞음.
반응형