Skip to main content
Discovery icon for Official Unity Discord Discord server

Official Unity Discord

31,210 Online
140,063 Members
# 💻┃code-beginner5 people

detecting enemies standing on blocks

Use Physics2D box casting or overlap checks with layer masks to detect enemies above hit blocks, passing correct output types.

  • A member needed to detect and hit an enemy standing on top of a block when the player hits the block from below
  • Using Physics2D queries like BoxCast or OverlapBox with an upward direction is recommended over custom dot product tests
  • Layer masks should be used instead of tags to filter collision queries specifically for enemies or players
  • When calling TryGetComponent on a RaycastHit2D result, target its transform and provide a correctly typed out variable instead of reusing the hit variable
Summarized from recent messages, might be inaccurate

More conversations

Talk, Play, &
Hang Out

Find your space to hang out, discuss the latest updates with the party chat, and see who's down to join your next match.
Get App