Error(8,20): Expected ‘,’ or ‘.’

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Watern’t

Well, I’m trying to make a camera that follows the character, and I’m guiding myself with chatgtp, so as not to ask everything, but I have a problem/error that not even botgtp can find.
The Error(8,20): Expected ‘,’ or ‘.’
(the script is from chatgtp, in fact, I don’t even know if it works for a camera that follows
the character).

(The line that appears in red is that of: func _process(delta: float): )

Here is the script:

class CameraFollower extends Sprite:
export var velocity = 10 

func _process(delta: float):
    var velocity = Vector2()
    if Input.is_action_pressed("move_right"):
        vel.x += velocity*delta
    var global_position = get_global_transform().origin
    var destination = get_viewport().get_camera().project_position(global_position)
    var direction = destination - global_position
    direction = direction.normalized()
    move_and_slide(direction * velocity * delta)

There’s no guarantee that ChatGPT will not produce buggy code. In fact, answers to Stack Overflow created using CHatGPT have been banned for this reason.

SteveSmith | 2023-01-20 16:14

:bust_in_silhouette: Reply From: magicalogic

Feels weird debugging AI code but anyway this line:

class CameraFollower extends Sprite:

should be two lines with no trailing colon:

extends Sprite
class_name CameraFollower

I wonder how the AI missed that.

It looks like got GodotScript and C# mixxed up.

SteveSmith | 2023-01-20 16:15

It continues with the blessed error, (the script is attached with the sprite, I took it from a tutorial on how to make the camera follow the character, but for some reason no errors appeared, but, as now, it changed a lot, I think not it will work.

extends Sprite

export var velocity = 10

func _process(delta: float):
var velocity = Vector2()
if Input.is_action_pressed(“move_right”):
velocity.x += velocity*delta
var global_position = get_global_transform().origin
var destination = get_viewport().get_camera().project_position(global_position)
var direction = destination - global_position
direction = direction.normalized()
move_and_slide(direction * velocity * delta)

Watern’t | 2023-01-20 20:56