Hey guys, is there a way in the engine to make a certain shape2D node visible? I mean visible like when you set 'visible collision shapes' on (but unlike it, not affecting everything until you manually switch all other shapes to invisible) or like when you put color to polygon2D.
visible shape2D
There is currently no way to toggle visibility for a single collision shape, so you have to draw it manually using a Polygon2D that matches the collider's points.
- Edited
Thanks! I thought I'd be wasting time going around something that's probably already implemented. I set those shapes in code from weapon types and statistics to create attack zones and projectiles, but setting up Polygons in code sounds daunting. I'm attempting to work around it by using built-in draw functions of those shapes. Unfortunately not much control over those, but hopefully I can rotate the canvas.
I put this inside the projectiles ready:
if debug_visibility: #shape.draw((get_tree().get_root().get_node("World").get_canvas_item()), Color( 0.86, 0.08, 0.24, 1 )) debug_canvas= Node2D.new() attacker.add_child(debug_canvas) shape.draw((debug_canvas.get_canvas_item()), Color( 0.86, 0.08, 0.24, 1 ))
yet it does not display in the current state. The commented out line displays as is should, yet I can't really rotate and move the main canvas so I add new one to the scene. My current problem is that the debug_canvas does not display anything at all. Has anyone got an idea what does not work up here?
- Edited
ok I made a tactical retreat and scale previously set shapes in code with scale property. Now I can just set polygons in editor for every type and should have desired results since they all will scale accordingly. I always thought that making shapes visible has to be an obvious feature. Thanks! My problems are solved.