0 votes

I have two splines and I trying to find the point of their intersections. I'm trying to do this through splitting spline into many small polygons.

func update_spline():
   var support = calc_support_points(start, target, stop)
   var kek = [start, support[0], target, support[1], stop]
   var tangets = compute_tangets(kek)
   points = spline(kek, tangets)
   var total_points = points + expand_into_polygon(points)
   var collision_points = total_points
   var groups = arc_convex_decomposition(collision_points)
   for group in groups:
       var shape = ConvexPolygonShape2D.new()
       shape.points = group
       self.shape_owner_add_shape(0, shape)

func _ready():
   self.connect("area_shape_entered",self, "_area_enter")

func _area_enter(area_id, area, area_shape_id, self_shape_id):
   var shape = self.shape_owner_get_shape(0, self_shape_id)
   var t = self.get_global_transform()
   var area_shape = area.shape_owner_get_shape(0, area_shape_id)
   var t2 = area.get_global_transform()
   var collision_points = shape.collide_and_get_contacts(t, area_shape, t2)
   cpos = self.to_local(collision_points[0]) # point of intesection

And here there is a problem. If I call updatespline in _ready then everything is fine. The event throws, and the intersection is detected. But if I do the same in _process, then I do not receive any "areashape_entered" events. What am I doing wrong?

asked Mar 8, 2018 in Engine by Alexander Tortsev (12 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.