0 votes
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"

in Engine by (16 points)

1 Answer

0 votes

It looks like:

input = input.normalized()

should be:

var dir = input.normalized()
by (3,545 points)

Thanks, it worked.

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 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 webmaster@godotengine.org with your username.