Use this guide to create or edit a Cannontower prefab with all required CannontowerView references and team visual pools.
Architecture Context
CannontowerView inherits from BuildingLevelStackView.
That means visuals are built from three team-based pool arrays:
- "_foundationPools”
- "_levelsPools”
- "_roofPools”
Unlike ArtilleryView, CannontowerView does not use "_buildingLevels".
Cannontower levels are built by stacked pooled parts plus level-based attack range values from "_ranges".
Pre-Setup Checklist
- Root object has CannontowerView component
- "_localTransform" is assigned
- "_aimNode" is assigned
- "_bulletNode" is assigned
- "_attackRange" is assigned
- "_foundationPools" has entries for all teams
- "_levelsPools" has entries for all teams
- "_roofPools" has entries for all teams
- "_ranges" count matches your intended level count
- "_levelMax" matches "_ranges" and gameplay settings
Scene View Gizmos (BuildingView)
- BuildingView draws a wire sphere in the Scene view at this object transform position.
- Radius matches TargetView "_radius" (same footprint used for clicks and combat checks).
- Wire color matches "_teamID" so you can scan team placement in the editor.
- Turn on Gizmos in the Scene view toolbar if you do not see it.
Main Procedure
Step 1: Duplicate a Working Prefab
- Duplicate Assets/GorodiskiGames/TowerClash/ResourcesStatic/Prefabs/Building/Cannontower.prefab.
- Rename the new prefab, for example CannontowerVariant.prefab.
- Open the duplicated prefab in Prefab Mode.
Step 2: Verify Required Hierarchy Links
2.1. Confirm these object references in CannontowerView:
- Transform (visual root) -> "_localTransform”
- AimNode -> "_aimNode”
- BulletNode -> "_bulletNode”
- AttackRange child (AttackRangeView) -> "_attackRange"
2.2. Confirm helper hierarchy groups exist under local transform:
- Foundations
- Levels
- Roofs
2.3. If any required reference is null, range visuals, bullet spawning, or tower stacking will break.
Step 3: Configure Core Building Values
3.1. Set gameplay-related values in CannontowerView:
- "_building" = Cannontower
- "_teamID" = default team for initial state
- "_radius" = click/target footprint
- "_foundationHeight" and "_levelHeight" = stack vertical spacing
- "_unitsCountDefault", "_unitsCountMax", "_levelMax" = gameplay limits
3.2. Important consistency rules:
- Keep "_levelMax" aligned with gameplay config
- Keep "_ranges".Length >= "_levelMax”
- Keep "_unitsCountMax" high enough to actually reach max level during gameplay
Step 4: Configure "_foundationPools”
4.1. Add one TeamPoolEntry per TeamIDType:
- Player
- Neutral
- Red
- Yellow
- Green
- Violet
- Magenta
- Cyan
4.2. For each entry, assign a ComponentPoolFactory that spawns the team-specific foundation prefab.
4.3. Rules:
- Do not leave a team missing
- Do not duplicate team IDs
Step 5: Configure "_levelsPools”
5.1. Add one TeamPoolEntry per TeamIDType.
5.2. Assign level segment prefabs for each team.
5.3. Runtime creates floor segments from this pool as level grows.
Step 6: Configure "_roofPools”
6.1. Add one TeamPoolEntry per TeamIDType.
6.2. Assign roof prefabs for each team.
6.3. Runtime places roof at the top of the current level stack.
Step 7: Configure Range Fields
7.1. Assign these combat fields:
- "_attackRange”
- "_ranges”
- "_minAttackRange”
7.2. "_ranges" rules:
- Index 0 = level 1 range
- Index 1 = level 2 range
- Index 2 = level 3 range
- Continue the same pattern if you add more levels
7.3. Keep "_minAttackRange" below all values in "_ranges".