The Identifier "dir" isn't declared in current scope

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Immortal Arts
extends KinematicBody

var curHP : int = 10
var maxHP : int = 10
var damage : int = 1

var gold : int = 0

var attackRate : float = 0.3
var lastAttackTime : int = 0

var moveSpeed : float = 5.0
var jumpForce : float = 10.0
var gravity : float = 15.0

var vel = Vector3()

onready var camera = get_node("CameraOrbit")
onready var attackCast = get_node("AttackRayCast")

func _physics_process (delta):
		vel.x = 0
		vel.z = 0

		var input = Vector3()


		if Input.is_action_pressed("move_forwards"):
			input.z += 1
		if Input.is_action_pressed("move_backwards"):
			input.z -= 1
		if Input.is_action_pressed("move_left"):
			input.x += 1
		if Input.is_action_pressed("move_right"):
			input.x -= 1

		input = input.normalized()

		vel.x = dir.x * moveSpeed <---Error
		vel.y = dir.y * moveSpeed

		vel.y -= gravity * delta

This is my code I am trying to create 3rd person movement following this tutorial: https://godottutorials.pro/action-rpg-godot-tutorial/
The error is : “The Identifier “dir” isn’t declared in current scope”

:bust_in_silhouette: Reply From: timothybrentwood

It looks like:

input = input.normalized()

should be:

var dir = input.normalized()

Thanks, it worked.

Immortal Arts | 2021-08-31 21:08