Using PhysicsEditor's outlines with LightOccluder2D

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By jarlowrey
:warning: Old Version Published before Godot 3 was released.

Trying to get PhysicsEditor’s exports to work with 2d light occlusion and collision. I’d rather use this program than manual vertex movement as it will be quicker and more accurate.

PhysicsEditor JSON output:

"enemyBlack4": [
        "density": 2, "friction": 0, "bounce": 0, 
        "filter": { "categoryBits": 1, "maskBits": 65535 },
        "shape": [   27, -1  ,  61, 0  ,  83, 15  ,  54, 82  ,  30, 84  ,  5, 66  ,  0, 13  ]
    } ,
        "density": 2, "friction": 0, "bounce": 0, 
        "filter": { "categoryBits": 1, "maskBits": 65535 },
        "shape": [   54, 82  ,  83, 15  ,  82, 62  ]

I created a sprite in the editor and attached a script to it. Inside the script I am attempting to load the vertices from JSON and add the LightOccluder2D and CollisionPolygon2D. For now I am using manually created vertices instead to get it working, but still when I run the following code no light masking appears.

func _ready():
# Called every time the node is added to the scene.
# Initialization here
var file ="res://assets/vertices/vertices.json",File.READ)
var game_data = {}

var polygon = Vector2Array([])
var end = 100

#var box =

var box2 =
var occluder =


Someone claims to have gotten an integration working on GitHub, but even if that’s true the occlusion polygon shape is not being drawn from the regular vertices. Any ideas?

The code does work when I copypaste it, although if you meant to make a box the vertices are in the wrong order, and you don’t need the square brackets in the Vector2Array declaration. Remember that you need a light in the scene that’s set to cast shadows or the occluder will be invisible. Other than that, check that your light masks are in order.

mollusca | 2017-04-19 22:36

Oh…it does work, thank you! I couldn’t tell due to a weak light energy interacting with a normal map. I appreciate it!

jarlowrey | 2017-04-19 23:11

:bust_in_silhouette: Reply From: jarlowrey

To get PE to work in godot I utilized the script I linked to on GitHub (here’s a better link), which allows you to export a single sprite from PE as a godot scene. Then you import that scene in to the engine. Trying to create the polygon from code was a bad idea.