Xrayez / godot-mesh-instance-collision-2d

An example project demonstrating an ability to create collision shapes from sprites via mesh instances in 2D

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Create collision shapes from sprites in Godot 3.1

Notice: this will not work in 3.0!

Notice 2: this is probably outdated with the new features added in 3.2:

Create CollisionPolygon2D

Instructions on how to create MeshInstance from Sprite

  1. Create a sprite and assign its texture. v

  2. Select the node sprite, at the top panel of the viewport click "Sprite".

  3. In the popup menu, press "Convert to 2D Mesh".

    Convert to 2D Mesh

  4. In the window dialog, press "Create 2D Mesh" button.

    Convert to 2D Mesh

  5. Study StaticBody2D.gd for further explanations.

The created MeshInstance can be used to retrieve its faces consisting of triangles which can be added to collision body dynamically.

About

An example project demonstrating an ability to create collision shapes from sprites via mesh instances in 2D

License:MIT License


Languages

Language:GDScript 100.0%