Working with Collision Layers in Unity

2D Mobile Game

Objective: Create a collision layer so that the sword ignores the player colliders when swing the sword

Now add two new layers player and sword and then select the player layer for player first and then select the sword layer for the hit box sprite inside the player gameobject.

Now go to Edit>Project Settings>Physics 2D and then de-select the sword layer for the player.

This will now allow the sword collider to ignore the player collider and the player can no longer be damaged by the sword swing.

--

--

--

Unity Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

The new era of micro frameworks, welcome Symfony 4

Bug in timbu.com

How to create your own little Restful Web API without getting lost in the process — Part 3…

NOTES TO FUTURE SELF

Creating Your First Vision Component From Maven Archetype Part 1

zCircuit PitStop #6 - Open Source

A DETAILED STUDY ON HOW 9,999 OUT OF 10,000 APPS WILL FAIL IN THE FUTURE

Five Strategies To Find the Right Software Development Partner

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Niraj Karki

Niraj Karki

Unity Developer

More from Medium

Adding another powerup — Shields

Unity new Input System : Smooth Movement (Part VI)

Day 100: Character Animation Part 3

Creating Elevator in Unity — Part 3: Moving Elevator.