Godot Version
4.6.2.stable.official
Question
Context: I have made a function in an autoloaded script (cinematic_controller), in which i tween the position of my camera to different locations. By running this function with arguments (tween-end-position, tween-duration, transition & ease type) i can move the camera in a bunch of different ways.
What i’m struggling with is how to use the two latter arguments (transition and ease) in the tween itself.
Here is the function:
- cinematic_controller.gd (autoload)
func move_cam(end_pos : Vector2, duration, transition, easing)
var tween = create_tween()
tween.tween_property(self, "cam_pos", end_pos, duration)
tween.set_trans(transition)
tween.set_ease(easing)
Here’s how i call it:
- mc.gd
cinematic_controller.move_camera(Vector2(0, 0), Vector2(200, 100), 5, "tween.TRANS_SINE", "tween.EASE_IN_OUT")
This gives the error:
Invalid type in function ‘set_trans’ in base ‘Tween’. Cannot convert argument 1 from String to int.
As a beginner to game development and a newcomer to gdscript this is confusing me. Converting the strings to int manually wouldn’t do me any good, so i honestly have no idea what to do here. The docs also didn’t mention (not that i found) anything about using arguments like this when tweening.
Thanks for any help and lmk if you need more details