i was following a tutorial on how to make a doom like game in godot but i can’t get the player to work
code:
extends CharacterBody3D
@onready var animated_sprite_2d_1 = $CanvasLayer/pistolbase/PISTOL
@onready var ray_cast_3d = $RayCast3D
@onready var shoot_sound_1 = $pistolsound
const SPEED = 5.0
const MOUSE_SENS = 0.5
var can_shoot = true
var in_the_grave = false
func _ready():
input.mouse_node = input.mouse_node_captured
animated_sprite_2d_1_finished.connect(SHOOT_ANIM_DONE)
$CanvasLayer/dead/Panel/Button.button_up.connect(restart)
func _input(event):
if in_the_grave:
return
if event is InputEventMouseMotion:
rotation_degrees.y -= event.relative.x * MOUSE_SENS
func _process(delta):
if input.is_action_just_pressed("QUIT"):
get_tree().quit()
if input.is_action_just_pressed("RESTART_THE_WHOLE_LEVEL"):
restart()
if in_the_grave:
return
if input.is_action_just_pressed("pew_pew"):
shoot()
func _physics_process(delta):
var input_dir = Input.get_vector("MOVE_LEFT", "MOVE_RIGHT", "MOVE_FORWARDS", "MOVE_BACKWARDS")
var direction = (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()
func restart():
get_tree().reload_current_scene()
func shoot():
if !can_shoot:
return
can_shoot = false
animated_sprite_2d_1.play("SHOOT")
shoot_sound_1.play()
if ray_cast_3d.is_colliding() and ray_cast_3d.get_collider().has_method("kill"):
ray_cast_3d.get_collider().kill()
func SHOOT_ANIM_DONE():
can_shoot = true
func kill():
in_the_grave = true
$canvaslayer/dead.show()
input.mouse.mode = input.mouse.mode.visible
errors:
Line 16:Identifier “input” not declared in the current scope.
Line 16:Identifier “input” not declared in the current scope.
Line 17:Identifier “animated_sprite_2d_1_finished” not declared in the current scope.
Line 27:Identifier “input” not declared in the current scope.
Line 29:Identifier “input” not declared in the current scope.
Line 34:Identifier “input” not declared in the current scope.
Line 69:Identifier “input” not declared in the current scope.
Line 69:Identifier “input” not declared in the current scope.