Coder Social home page Coder Social logo

boxcollidergenerator's Introduction

Problem/Solution

If you're using Aron Granberg's A* package and Toolkit 2D's tilemap solution with Unity's new 2D features, you might have a bit of a problem with A* finding your tiles. This is because tk2d's tilemap generates colliders using EdgeCollider2D meaning your "walls" are not solid. This simple script aims to fix that problem. Basically it loops through your map, finds colliders and drops a BoxCollider2D into a colliders place.

Usage

Drop the ColliderBuilder folder into your project, then create an empty GameObject add the ColliderBuilder.cs script to it. Tell ColliderBuilder what map you're using and what layer you want the colliders to be draw on (this is for A*'s collision testing feature), then hit Create Colliders. Finally head over to A*s graph generator, set the collisions testings mask to your chosen layer and scan the grid. If everything goes well and your walls are found, simply cache the grid then click "Remove Colliders" to remove the generated BoxCollider2D's.

Limitations

This scripts finds tiles with ANY collider on it and draws a collider in that position. That means it doesn't care if it's a box collider, polygon collider or circle collider.

Visual Guide

  1. Set Layer Step 1

  2. Generate Colliders Step 2

  3. Set Layer (Mask) in A* Step 3

  4. Generate A* graph Step 4

boxcollidergenerator's People

Contributors

kevinruscoe avatar

Watchers

James Cloos avatar Nicholas DiMucci avatar  avatar

Forkers

manlan

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.