This is an old revision of the document!
For our regular monthly tutorial nights, we're basing our teaching on the wonderful series by AJ's Learning Lab, Godot FPS Tutorial - Learn Godot by making Wolfenstein 3D.
He has made the assets he uses freely available (please consider donating) here: https://ajslearninglab.itch.io/boganstein-3d-learn-godot-4-with-wolfenstein-3d/
All the code we use is available on AJ's Learning Lab github - https://github.com/AJsLearningLab/GodotFPS
extends CanvasLayer
var ammo = 0
var current_weapon = "knife"
func _ready():
$AnimatedSprite2D.animation_finished.connect(_on_AnimatedSprite2D_animation_finished)
func _process(delta):
if Input.is_action_just_pressed("ui_select"):
if current_weapon == "knife":
$AnimatedSprite2D.play("stab")
elif current_weapon == "gun":
if ammo > 0:
$AnimatedSprite2D.play("shoot")
ammo -= 1
func _on_AnimatedSprite2D_animation_finished():
if current_weapon == "knife":
$AnimatedSprite2D.play("knife_idle")
elif current_weapon == "gun":
$AnimatedSprite2D.play("gun_idle")