This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

HI, when I am using interpolations on Tween nodes last 2 arguments apeaar as enum values, I am interested in how to do that, I know it is not necessary, I could pass an enum value in func call but, this is most comfortable especially when func is called outside the original script

Enums in Tween arguments


enum items {sword, shield}


func equip(item = items): # dosen't work as tweens
Godot version 3.4.2
in Engine by (40 points)

1 Answer

+1 vote
Best answer

You just need to have a class of a node with those enums.

extends RigidBody2D
class_name Player
enum items {sword,shield}

From that moment You can call from everywhere in the script :

by (8,188 points)
selected by

Hi, maybe I wasn't clear at all, I know how to use an enum, I was asking how to show a list of enum's values when I set arguments in a call func that use them. Even using class_name that list didn't appear, do you have an example in func build?

Introducing a class to system is all it takes to show its enum list from everywhere You call. Once You create a class using classname Godots compiler shows it in a node list and autocompletes in editor. In example above I created Player class. Now I can start writing in random script "Pl" and editor will autocomplete "Player". Now if I input dot : "Player." compiller will show every function and every enum of Players script, including .sword and .shield. It works the same way as You use Tween.TRANSBACK

Okey, now I understand a bit more about Godot thanks for it, I didn't know how class_name really works, but look this

I set class_name

extends KinematicBody2D
class_name Player

now it works as you said everywere, thanks


but as you can see in the pictures I did not write Tween. I came to the last 2 arguments and automatically appear a list that includes tween.enum's values, I am sure there is someting on this func to show a specific enum automatically in that argument, only for wirte "," before is needed the enum

enter image description here
enter image description here

this is not happening when I use equip(), then I realise something


but I haven't success


you reserve a vote for your time, I will try to be more specific on my questions, have a good day.

Aaah ok I finally understood what You meant :P
I did some digging and found article covering that :

unfortunately, it specifically says, that it is impossible to cast enums in Godot :(. That means compiler can't be informed about variable being enum, and it will never autocomplete like built_in Tween enum :/

Hooo well, thanks for it, even it is impossible I learned some useful things, take your best answer!

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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.