Unity/Asset 분석

[RTS Engine] 공격 사거리

lipnus 2021. 6. 4. 02:52
반응형

당연히 있어야 될 것 같은

사정거리라는 변수가 없어서

어떤 구조인지 파악하기가 힘들었다.

 

 

① 상대편 유닛을 공격할때 사정거리를 설정하는 경우 (Unit Stopping Distance)

 

Unit Stop Distance 값을 조정

Unit/Building Stopping Distance: When moving towards a target unit/building, this field is the minimum and maximum allowed stopping distance value for that movement.

 

 

일단 Max가 사정거리.

 

 

코드 보면..

(min=true) Max거리 밖에서 적을 마우스로 직접 찍으면 Min 거리에 가서 쏨 

(min=false) 이외에는 Max거리까지 가서 쏘거나 현재 위치에서 쏨.

 

 

 

 

특별한 사항이 아니면,

그냥 Min, Max 똑같게 해놓으면 될듯.

 

UnitAttackRange.cs

min이라는 변수가 True이면 Min거리반환

/// <summary>
        /// Get the appropriate stopping distance for an attack depending on the target type.
        /// </summary>
        /// <param name="target">FactionEntity instance that represents the potential target for the unit.</param>
        /// <param name="min">True to get the minimum value of the stopping range and false to get the maximum value of the stopping range.</param>
        /// <returns>Stopping distance for the unit's movement to launch an attack.</returns>
        public float GetStoppingDistance (FactionEntity target, bool min = true)
        {
            float stoppingDistance;

            EntityTypes targetType = target ? target.Type : EntityTypes.none;
            switch(targetType)
            {
                case EntityTypes.unit:
                    stoppingDistance = min ? unitStoppingDistance.min : unitStoppingDistance.max;
                    break;
                case EntityTypes.building:
                    stoppingDistance = min ? buildingStoppingDistance.min : buildingStoppingDistance.max;
                    break;
                default:
                    stoppingDistance = min ? noTargetStoppingDistance.min : noTargetStoppingDistance.max;
                    break;
            }

            return stoppingDistance + (target ? target.GetRadius() : 0.0f);
        }

 

Search Range

이 안에 들어오면 반응

 

Search Reload

한명 찾고, 죽이던가 해서 다음 유닛 찾을 때 까지의 딜레이?

 

 

 

 

 

 

Attack Component – General

General Settings of the attack component. Units and buildings will be referred to as faction entities. Is Locked: When enabled, the faction entity will not be able to use this attack type or switch to it. Is Active: When enabled, the faction entity will b

soumidelrio.com

 

 

Unit Attack Range

The Unit Attack Range is a field that allows different attack range parameters for an attack unit. This field can be found on the following components: Unit/Building Stopping Distance: When moving towards a target unit/building, this field is the minimum a

soumidelrio.com

 

반응형