Godot Version
4.1.3.stable.official
Question
Hi! I’m used to object-oriented languages and am just now getting to Godot.
I have one script, for example SmoothMotion.gd:
var targetPos = position;
@export_range(0.0, 1.0, 0.05) var moveLerp : float = 0.1;
func _process(delta):
position = lerp(position, targetPos, moveLerp);
and would like to use it in conjunction with a few other scripts attached to the same node that might modify targetPos.
Is there a way to require SmoothMotion.gd also be attached to the node if I use one or more of the others?
I know I could extend the script, but then what if I want to require multiple? And what happens if two scripts extend it and want to modify the same variable?
I’ve seen a few uses of the preload function, and it seems like the solution could be in there, but I’m having trouble understanding if that creates a new instance of the class or allows me to modify the node’s instance of it (and therefore the variables held there).
Let me know if my question’s unclear or anything, thanks!