This page explains how collisions work in the TopDown Engine.

Introduction

The engine’s TopDownControllers, whether we’re talking about the 2D or 3D versions, are built on Unity’s foundations. The 2D one will pilot a RigidBody2D, while the 3D version pilots a CharacterController. So for collisions you’ll need colliders, set on your characters and obstacles/ground/etc.

Layers

The engine relies on layers to identify certain objects, notably walls and agents. Layers are metadatas you can associate your gameobjects with, and you can then use these to casts rays on certain layers only, via Layer masks (a selection of layers). Note that layers and sorting layers are completely different things. There are no restrictions or naming conventions regarding sorting layers in the TopDown Engine.

Here’s a list of the main layers used by the engine. Note that the only mandatory ones are the platform related ones :

  • Ground : whether you’re in 2D or 3D, this marks the colliders that will be considered as ground (and walkable) by your characters.
  • Obstacles : colliders that will stop your character from walking, from getting up if they’re in a tunnel, and will stop your bullets as well.
  • MovingPlatform : for all your moving platforms.
  • Enemies : put all colliders belonging to enemies (that will hurt and get hurt by your character)
  • Hole : for 2D only, mark colliders with this tag and characters will consider them as holes they can fall down into
  • FallingPlatform : for all your falling platforms
  • Projectile : a layer to put all projectiles colliders on
  • Player : the layer to put the player’s colliders on
  • ObstaclesDoors : a special layer to put certain safety areas around 3D doors, to convey that information to the pathfinding AI
  • NoPathfinding : a layer to put colliders you want the pathfinding AIs to avoid

Tags

Tags are metadata you can add to your gameobjects to find them easier from other scripts. The engine doesn’t rely on tags at all. Feel free to keep using them in your scripts though!