Curve changes for all of the children

I have a scene of a fighter, who throws “bombs” lets say. it work perfectly, curve is good and projectiles go where they need, but if I have two fighters on battleground they seem to share one curve, but it goes from their own eyes. First one that is closer to an enemy shoots a ball, but the next second another fighter shoots another ball and ball of the first one goes by the curve of the second, starting from his eyes, but folowing the path.
Here’s an example:


Godot Engine 2025.05.04 - 02.58.37.09.DVR (online-video-cutter.com) (1)
You can see here that right fighter shoots ball, but it quickly changes its direction.
Code that works with curve:

var proj = preload("*/proj.tscn")
@onready var curve = $proj_path.get_curve()
@onready var proj_path = $proj_path

Somewhere somewhere later after all checks and in _process function:

curve.set_point_position(1, first_enemy.get_global_position() - proj_path.get_global_position())
curve.set_point_out(0, Vector3(curve.get_point_position(1).x, tilt, curve.get_point_position(1).z))
var new_proj = proj.instantiate()
proj_path.add_child(new_proj)

variable tilt is either 1 or 0
Projectile starts moving as soon as it spawns and when reaches the end (proj_path.progress_ration == 0) apllies damage and queue_free() itself.
Any help is appreciated.

Well that does look like they do not have seperate paths, but are sharing the same one. So when one calculates the path it is changing the path of the other one too.

When you duplicate a scene or a node group, copied resources will often share the same single resource. If you right click it you will see an option for ‘make_unique’ in the resource dropdown. Not knowing your tree or how you created these, or where you are storing or creating your curves or paths, I could not say more, but you definitely do not have a unique path by the looks of things.

Anyway, I hope that helps in some way.

PS In the same way if you copy a button that has a style applied, and you change the style on the new button, as the style is not yet unique so the first button will also change. I can’t think of a better example than that, sorry. The same applies to paths and curves and any resource you duplicate or copy.

PS In code it would be something like:

var curve = Curve2D.new()
new_proj.curve = curve
add_child(new_proj)

Thanks a lot!!!
That was a problem. Since every fighter instance has path3d in it, it had setted curve, so I fixed it with creating a new one each time it has to throw a bomb:

proj_path.set_curve(Curve3D.new())
var curve = proj_path.get_curve()
curve.add_point(Vector3.ZERO)
curve.add_point(first_enemy.get_global_position() - proj_path.get_global_position())
curve.set_point_out(0, Vector3(curve.get_point_position(1).x, tilt, curve.get_point_position(1).z))
var new_proj = proj.instantiate()
proj_path.add_child(new_proj)


As you can see (if it can be), curves are visible and went into bad guys, thanks again!!!

1 Like