I have created global variables:
var tutor_count = 0
var tutor = false
extends CharacterBody3D
func _physics_process(delta: float) -> void:
if not is_on_floor():
velocity += get_gravity() * delta
var input_dir
if auto.tutor == false:
if auto.tutor_count == 0:
if Input.is_action_just_pressed("tutorial") and is_on_floor():
velocity.y = JUMP_VELOCITY
input_dir = Input.get_vector("tutorial", "tutorial", "forward", "tutorial")
if auto.tutor_count == 1:
if Input.is_action_just_pressed("tutorial") and is_on_floor():
velocity.y = JUMP_VELOCITY
input_dir = Input.get_vector("tutorial", "tutorial", "forward", "backward")
if auto.tutor_count == 2:
if Input.is_action_just_pressed("tutorial") and is_on_floor():
velocity.y = JUMP_VELOCITY
input_dir = Input.get_vector("left", "tutorial", "forward", "backward")
if auto.tutor_count == 3:
if Input.is_action_just_pressed("tutorial") and is_on_floor():
velocity.y = JUMP_VELOCITY
input_dir = Input.get_vector("left", "right", "forward", "backward")
if auto.tutor_count == 4:
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y = JUMP_VELOCITY
input_dir = Input.get_vector("left", "right", "forward", "backward")
elif auto.tutor == true:
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y = JUMP_VELOCITY
input_dir = Input.get_vector("left", "right", "forward", "backward")
var direction = (Head.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction:
velocity.x = -direction.x * SPEED
velocity.z = -direction.z * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
velocity.z = move_toward(velocity.z, 0, SPEED)
move_and_slide()
I also have a separate “CanvasLayer” scene in which the “Label” output is processed and the “tutor_count” is calculated depending on the level of progress.
extends CanvasLayer
func _input(event: InputEvent) -> void:
if event.is_action_pressed("forward") && auto.tutor_count == 0:
movement_w.visible = false
movement_s.visible = true
auto.tutor_count += 1
if event.is_action_pressed("jump") && auto.tutor_count == 4:
movement_jump.visible = false
auto.tutor = true
auto.tutor_count = 0
visible = false
queue_free()
Of course, I didn’t insert all the code, but parts of it, but I hope this doesn’t interfere with understanding.
UPD: The “tutorial” is an empty action, meaning its InputMap is empty.