Enum not working as shown in lesson

I’m not sure why this is happening, this is how it is shown to be done in the lesson, however, I can’t use it like that.

I’ve noticed that as of Godot 3.1 you can no longer access the enum the way it is done in the video but you have to put the name of the enum in front, followed by a . (vision_mode.NIGHTVISION)

If you use a variable to store the vision mode in use it will work

extends "res://Scripts/Character.gd"

var motion = Vector2()
var torchEnable = false
enum vision_mode {DARK, NIGHTVISION}
var vision_mode_in_use = vision_mode.DARK

func _ready():
	Global.Player = self
	#vision_mode = DARK

func _process(delta):

func update_motion(delta):
	if Input.is_action_pressed("ui_up") and not Input.is_action_pressed("ui_down"):
		motion.y = clamp((motion.y - SPEED), -MAX_SPEED, 0)
	elif Input.is_action_pressed("ui_down") and not Input.is_action_pressed("ui_up"):
		motion.y = clamp((motion.y + SPEED), 0, MAX_SPEED)
		motion.y = lerp(motion.y, 0, FRICTION)
	if Input.is_action_pressed("ui_right") and not Input.is_action_pressed("ui_left"):
		motion.x = clamp((motion.x + SPEED), 0, MAX_SPEED)
	elif Input.is_action_pressed("ui_left") and not Input.is_action_pressed("ui_right"):
		motion.x = clamp((motion.x - SPEED), -MAX_SPEED, 0)
		motion.x = lerp(motion.x, 0, FRICTION)

func _input(event):
	if Input.is_action_just_pressed("ui_vision_mode_change"):

func cycle_vision_mode():
	if vision_mode_in_use == vision_mode.DARK:
		get_tree().call_group("interface", "NightVision_mode")
		vision_mode_in_use = vision_mode.NIGHTVISION
	elif vision_mode_in_use == vision_mode.NIGHTVISION:
		get_tree().call_group("interface", "DarkVision_mode")
		vision_mode_in_use = vision_mode.DARK

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.