0 votes
extends KinematicBody

const MINCAMERAANGLE = -60
const MAXCAMERAANGLE = 70

export var camera_sensitivity: float = 0.05
export var speed: float = 10
var velocity: Vector3 = Vector3.ZERO

onready var head: Spatial = $Head

func ready():
Input.set
mousemode(Input.MOUSEMODE_CAPTURED)

func physicsprocess(delta):
var movement = _get
movement_direction()

velocity = movement * speed
velocity = move_and_slide(velocity)

func unhandledinput(event):
if event is InputEventMouseMotion:
handlecamera_rotation(event)

func handlecamerarotation(event):
rotate
y(deg2rad(event.relative.x * camerasensitivity))
head.rotate
x(deg2rad(-event.relative.y * camerasensitivity))
head.rotation.x = clamp(head.rotation.x, deg2rad(MIN
CAMERAANGLE), deg2rad(MAXCAMERA_ANGLE))

func getmovement_direction():
var direction = Vector3.DOWN

    if Input.is_action_pressed("forward"):
        direction -= transform.basis.z
    if Input.is_action_pressed("backwards"):
        direction += transform.basis.z
    if Input.is_action_pressed("left"):
        direction -= transform.basis.x
    if Input.is_action_pressed("right"):
        direction += transform.basis.x

        return direction
Godot version v3.4.4.stable.official [419e713a2]
in Engine by (12 points)

1 Answer

0 votes

Error does not originate in this part of code. You introduced var movement as local variable for physics_process(), but You must have used it somewhere out of this function, and this somewhere is provoking error. You can read which line of code your error is.

by (5,651 points)
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.