I have these sawblades I've made that follow a path around, but there's two things I can't quite figure out myself.
1: how can I have multiple blades in one scene that each use unique paths? if I try to edit one blade's path it just makes another point that both of them end up following!
2: how can I visually represent the paths in the game itself? I want the player to know the path the blade is going to take, but I don't know how I'd add color or images to draw it out.

ideally after these two questions get answered I can add new sawblades by just plopping one in and drawing out it's own new unique path.

  • samuraidan Actually to draw simple line same as Path2D you can just do something like (that is script attached to Line2D):

    extends Line2D
    
    @export var target_path : Path2D
    
    func _ready():
    	points = target_path.curve.get_baked_points()

    Then you need to select Path2D node as target_path and it should be working.

You need to have separate Path2D nodes and in each of them unique Curve property. You can make sure that it is unique by right clicking it and selecting Make Unique.
For visuals, you could add a Line2D child to Path2D and on _ready create a line based on the curve of the path. So in pseudo code it would look like this:

for i in number_of_points:
    offset = path2d.sample(i/number_of_points)
    self.points.append(offset)

IIRC there were also some addons for working with curves and other shapes, so you could try those

    that second bit's a little too complicated for me to try right now, so I'll get back to that.
    as to the first part, it was actually even simpler than you said. I just had to go into the path2D node, click the curve2D and in the drop down menu click "make unique". I guess since I was instancing scenes it was already counting as separate nodes.

    also this is just a personal thing but I try not to use add-ons because I'm having a hard enough time learning what's there already.

    you could create a certain amount of predefined behaviors that you want (and I mean this would be a somewhat limited amount), using an initial value that would depend on an export var (example if export var direct_y is true the saw goes up and down and otherwise moves from left to right), you could also create tell it how much you want it to move through a value of an export var of numeric type (example if export var mov is equal to 100 move in 100 if it is 50 move in 50).
    sorry for some mistake in the syntax I use a translator because I am a lazy person who does not want to learn english.

    LoipesMas

    my brain is trying to grok that example code, but I'm having some issues:
    sample() is not found in base Path2D, nor is it found in the name of my actual path2D node.

    and how do I get the number of points? self.Points? I'm attaching the script to the path2D node itself because it's at the top of the hierarchy.

      samuraidan Actually to draw simple line same as Path2D you can just do something like (that is script attached to Line2D):

      extends Line2D
      
      @export var target_path : Path2D
      
      func _ready():
      	points = target_path.curve.get_baked_points()

      Then you need to select Path2D node as target_path and it should be working.

        LoipesMas sorry bout that, I don't know the engine well enough (especially v4) to know what does and doesn't work or exist sometimes.

        GlyphTheWolf that works perfectly! these kind of one line solutions that do exactly what I want but have no decent way of finding myself is exactly why I come here. thanks a lot!!