Layers and tags in unity

Forum posted on

Project: Armament

Open a forum with the team to discuss possible layer and tags that we will utilize during the course of production.  

Unity uses layers and tags to help associate objects and their place in the world.  https://docs.unity3d.com/Manual/class-TagManager.html here is what unity has on layers and tags.  Right now here is the list of tags we have either by default or we created.

  1. respawn
  2. finish
  3. editor only
  4. maincamera
  5. player
  6. gamecontroller
  7. environ
  8. imovable
  9. imovablechild
  10. ground
  11. playerunit
Can anyone think of any other tags we would use in the future or might want to otherwise?  



I think we should also talk about navmesh as that relies heavily on unity tags i think and theres another layer system with navmesh.   

https://docs.unity3d.com/Manual/nav-InnerWorkings.html

This might be helpful i think im still trying to figure out navmesh but its really simple.  This is where we would assign whether something was the ground or if the terrain is water and would control where units can and cannot go.  At this time we are only using the defaults

  1. Walkable
  2. not walkable
  3. jump

So we should also get a list together covering possible navmesh agents we would use.  Water being obvious but also buildable surfaces?  




Layers and tags in unity

On the Layer topic we should have a layer for the list below.  These game objects will need to be targeted by other units but not targeted by the same unit.  Like anti aircraft gun will only shot aircraft/helicopters. We can only have 22 layers i think 8 to 31 so we need to use these to help define our global game objectives.

Layers:
  1. Aircraft
  2. Helicopter
  3. Surface
  4. Submarine
  5. Vehicle
  6. Space
  7. Infantry
  8. Structure
  9. Terrain
  10. Network Game Object
  11. Environmental Static Objects (Non destroy-able object a structure or tree line)
  12. Environmental Dynamic Objects (Bridge that can be destroyed)
@Team Do we know if we can attach more then one layer and/or tags to each game object or is it a one to one relationship.

For the tags these are so we can find object in the game.  Versus Layers which are to share a common attribute.

Tags:
  1. Spawn
  2. Main Camera
  3. Players
  4. Game Manager?
  5. Officers?

@Robert can you list all the tags/layers you are using to define game object in the came currently please.

For navMesh I think the above layers will help define what it needs base on the attributes listed above.


Thanks,
James Fleming 
Facebook
Discord

1.
Layers i used so far:
8. Ground,
9. Building,
12. PlayerUnit.

I had EnemyUnit also but unity deleted it, and it can only be used for singleplayer, for multiplayer il have to figure out something different.

2.
Tags:
playerUnit
Ground.

3.
As for your question @James , you can only have one layer/tag per unit.

4.
For handling what unit type can attack what, that should be handled in code since we have so many units.

5.
NavMesh uses its own layer sistem, and navMeshAgent (our units), can be set up using that so they move on water, but not ground etc..

737.43 SSgt Jono Lansdale Artist 3D
8/4/2018 7:31:53 PM

Navmesh tags we should figure out i can think of three right away being land water and air where air would combine land and water navmesh with maybe some exceptions to certain altitudes.  I know though Robert your experimenting with that now and im eager to hear about what you find.

We should definitly come up with a comprehensive list for what we plan on using.  We might make modifications when we need to but lets get a good foundation starting.

 

So what we need is 

Object TAG (unlimited)

  1. untagged
  2. Respawn
  3. Finish
  4. EditorOnly
  5. MainCamera
  6. Player
  7. GameController
  8. Environ
  9. IMovable
  10. ImovableChild
  11. Ground

Object Layers (31 available first 8 cannot be changed)
    0.  Default

  1. TransparentFX
  2. Ignore Raycast
  3. -
  4. Water
  5. Ui
  6. -
  7. -
  8. Ground

These are the first 8 what would also go here?  Maybe a units layer?  Im not 100% about the logic going into layers and tags for objects.  Is it like photoshop layers or more like logic that affects everything on the layer?  

NAVMESH Layer (31 available)

  1. Walkable 
  2. Not walkable
  3. Jump



We also have agents currently we use Vehicle does this function the same as tags?  So would we have a vehicle, sea, air agents with just walkable and not walkable layers?

Or a [Units] Agent with land, air, water navmesh's?  are you also looking into this too robert?


@Jono I want you to lable out what each of those tags & layer system are used for?  Then compare them to my list below and consolidate them down.

So what we need is 

Object TAG (unlimited)

  1. untagged
  2. Respawn
  3. Finish
  4. EditorOnly
  5. MainCamera
  6. Player
  7. GameController
  8. Environ
  9. IMovable
  10. ImovableChild
  11. Ground

Object Layers (31 available first 8 cannot be changed)
    0.  Default

  1. TransparentFX
  2. Ignore Raycast
  3. -
  4. Water
  5. Ui
  6. -
  7. -
  8. Ground
@Robert Once these layers for navMesh etc are created lets create an Enum code for each and put them in a model for use?

@Robert Given my list below please slow consolidate down what you have used into the list I have created.

@Robert Why would we have both a layer and tags called playerunit?

@Team If the item is not there you need then just added I want one complete list for this to start with.

Thanks,
James Fleming 
Facebook
Discord

note to myself - list need to be updated when new tag/layer is introduced or something changed.


LAYERS - for now they are used only for raycasting (for example when you click on something mouse pointer will cast ray and if hits unit with unit layer it will select it.)

5. UI - unity layer used for all UI elements by default.

8. Groung - used on terrain, at moment only for getting position for units movement.

9. Building - used on buildings/structures. Its set in ScriptBuilding.cs, assign when you press play button in unity so no need to assign it manually.

10. PlaceableBuilding, used on buildings when moving them with mouse on creating new building to prevent them from building on top of other structures.

12. PlayerUnit - used on units, for selection only at the moment. Set in ScriptUnit.cs. 

TAGS - used for referencing objects in script (usually on Awake method).

3. playerUnit, for referencing when selecting multiple units

4. Ground - not sure when I used it, could be in some old script, or its default tag in unity.

5.EndUserUI - To reference Graphical user interface.

I couldn't come up with a lot of layers besides the ones you already had, judging from the GDD I don't think there's a lot more to add.

The layers I thought of were:

13. Enviroment (trees, rocks, bushes, grass, etc)

14. Particles (Details that are part of the enviroment but are usually in the air like little insects or stuff like that)

15. neutral units ? (I'm not sure if there are going to be neutral units wandering around in the map so i just threw this out there really)

16. Projectiles (Things like rockets that come out of rocket launchers, helicopters, tanks and stuff. Maybe if you plan to add bullets to the basic attacks too they could be in this layer)