2:55 you can transform the polygon like this: "var offset_poly = Transform2D(0, poly.global_position) * poly.polygon" note: here offset_poly is the list of points not a Polygon2D, so later when you clip them pass in offset_poly not offset_poly.polygon
Good video. It would be a lot more beginner friendly if you highlighted the elements you're referring to on screen somehow so that your explanation is easier to follow. Thank you for the vid.
@@mrelipteach I think we do not understand the ready-made codes because they confuse the recipient It is ready information In the end, I don't know why I love you so much
For peoples who want 'islands': add this code under the setting polygon stuff if res.size() > 1: var island := Polygon2D.new() var island_collision := CollisionPolygon2D.new() island.polygon = res[1] island_collision.set_deferred('polygon',res[1]) add_child(island_collision) add_child(island) yeah its bad but its working :D
Your version can only have two "islands". Here is an improved version with an infinite number of "islands":Your version can only have two "islands". Here is an improved version with an infinite number of "islands": if res.size() > 1: for i in range(len(res)): var island := Polygon2D.new() var island_collision := CollisionPolygon2D.new() island.polygon = res[i] island_collision.set_deferred("polygon", res[i]) $collision.add_child(island_collision) add_child(island)
@@saslow_dev I'm trying to implement this, but when I create an island, the entire polygon turns white and loses all collision. What is the $collision referred here?
Hey ! Loved the tutorial :) . I had a problem with the implementing of the terrain destruct though. Whenever i fire the missiles at a same spot for two three times , the destruction stops working and the engine gives me decompose_polygon_in_convex: Convex decomposition failed! error. And as such when i enable visible collision shapes , whole collision shape gets deleted after the third missile hitting the same spot. Could you highlight what the problem could be?
@@mrelipteach I got some aspects of it worked out, but I am sure I am missing something. And I even made mine simpler, was only doing bullets that don't even arc, just drop straight down (space invaders type game, pillboxes are what I want to have destroyed) but it's still not working right. . Like now it's PackedVector2Array, Geometry2D.clip_polygons, and so on, but still....no luck.
Hey all ! This tutorial is perfect for what I need but I wanted to know if anyone knew if it's possible to turn this kind of flat plane into a 3d object. Give it a thickness. Like Worms Revolution or Battlegrounds ?
I have discovered the issue with this project. Clipping only works if destructible object is at coordinates 0,0. It can sort of work if it's close to 0,0 and destruction polygon can cover the difference, but clipping still takes at wrong place. I am trying to fix it. It seems that local coordinate points of Polygon need to be transformed to their global position in scene but I don't know how. "$Polygon2D.polygon" in "var res = Geometry2D.clip_polygons($Polygon2D.polygon, offset_poly.polygon)" should be replaced to global values. So if let's say the object is located at 100, 100, the first retrieved value of point in "$Polygon2D.polygon" should be 100, 100 instead of 0,0 EDIT: Fixed code: var offset_poly = Transform2D(poly.get_parent().get_parent().rotation, poly.global_position) * poly.polygon var global_polygon: PackedVector2Array = Transform2D(0, $Polygon2D.global_position) * $Polygon2D.polygon #
2:55 you can transform the polygon like this: "var offset_poly = Transform2D(0, poly.global_position) * poly.polygon"
note: here offset_poly is the list of points not a Polygon2D, so later when you clip them pass in offset_poly not offset_poly.polygon
Good video. It would be a lot more beginner friendly if you highlighted the elements you're referring to on screen somehow so that your explanation is easier to follow. Thank you for the vid.
in version 4.1 it doesn't work.
Please do you know what the new code would be like?
I don't really know why it wouldn't work. Do you have an error or something?
The Geometry class is now Geometry2D, so you can mass replace that, and then comment out update()
@@mrelipteach
I think we do not understand the ready-made codes because they confuse the recipient It is ready information In the end, I don't know why I love you so much
Its was really helpful. Thank you
For peoples who want 'islands':
add this code under the setting polygon stuff
if res.size() > 1:
var island := Polygon2D.new()
var island_collision := CollisionPolygon2D.new()
island.polygon = res[1]
island_collision.set_deferred('polygon',res[1])
add_child(island_collision)
add_child(island)
yeah its bad but its working :D
Your version can only have two "islands". Here is an improved version with an infinite number of "islands":Your version can only have two "islands". Here is an improved version with an infinite number of "islands":
if res.size() > 1:
for i in range(len(res)):
var island := Polygon2D.new()
var island_collision := CollisionPolygon2D.new()
island.polygon = res[i]
island_collision.set_deferred("polygon", res[i])
$collision.add_child(island_collision)
add_child(island)
@@saslow_dev Yeah thats better, tjamls!
@@saslow_dev I'm trying to implement this, but when I create an island, the entire polygon turns white and loses all collision. What is the $collision referred here?
@@saint-frog I think it refers to the destructible static body
Hey ! Loved the tutorial :) . I had a problem with the implementing of the terrain destruct though. Whenever i fire the missiles at a same spot for two three times , the destruction stops working and the engine gives me decompose_polygon_in_convex: Convex decomposition failed! error. And as such when i enable visible collision shapes , whole collision shape gets deleted after the third missile hitting the same spot. Could you highlight what the problem could be?
hermoso... como puedo hacer la linea que te indica la dirección del proyectil... así como la que hiciste en tu juego
I made a video about that specifically ruclips.net/video/Mry6FdWnN7I/видео.html
Great tutorial! I am trying to create similar terrain, is there tutorial on how to do it?
Thanks! I have a video on using path2D, polygon2D ,etc.. you'll find what you need: ruclips.net/video/nt98ROm_Jrs/видео.html
@@mrelipteach wow, this is exactly what I needed! Thank you!
Wicked awesome godot is
Any chance of updating this to Godot 4? I tried things as you had them here and a lot of the stuff has changed.
I can't promise anything. It would take a lot of time to go through the many experiments and update them.
@@mrelipteach I got some aspects of it worked out, but I am sure I am missing something. And I even made mine simpler, was only doing bullets that don't even arc, just drop straight down (space invaders type game, pillboxes are what I want to have destroyed) but it's still not working right. . Like now it's PackedVector2Array, Geometry2D.clip_polygons, and so on, but still....no luck.
Hey all !
This tutorial is perfect for what I need but I wanted to know if anyone knew if it's possible to turn this kind of flat plane into a 3d object.
Give it a thickness.
Like Worms Revolution or Battlegrounds ?
funciona en godot 4
Having tough time to digest the code❤❤❤
Really helpful
Glad it helped
I have discovered the issue with this project. Clipping only works if destructible object is at coordinates 0,0.
It can sort of work if it's close to 0,0 and destruction polygon can cover the difference, but clipping still takes at wrong place.
I am trying to fix it. It seems that local coordinate points of Polygon need to be transformed to their global position in scene but I don't know how. "$Polygon2D.polygon" in "var res = Geometry2D.clip_polygons($Polygon2D.polygon, offset_poly.polygon)" should be replaced to global values.
So if let's say the object is located at 100, 100, the first retrieved value of point in "$Polygon2D.polygon" should be 100, 100 instead of 0,0
EDIT: Fixed code:
var offset_poly = Transform2D(poly.get_parent().get_parent().rotation, poly.global_position) * poly.polygon
var global_polygon: PackedVector2Array = Transform2D(0, $Polygon2D.global_position) * $Polygon2D.polygon #