Godot Version
4.2.2.stable
Question
Hello! I am making a 2D platformer game, and up to this point have had standard pathing enemies that walk back and forth. Now, I am trying to create a boss which will have actual attacks and corresponding animation, but I’m not really sure where to begin with that process. Currently I have the boss set as a StaticBody2D, but I’m unsure if it will need to be changed to a CharacterBody2D (I do not plan to have the boss move, only throw projectiles).
My code for my boss looks like this currently:
extends StaticBody2D
class_name Flamagor
@onready var anim = $AnimatedSprite2D
@onready var enemExpSpawnPoint: Marker2D = $Marker2D
@onready var flamagor_collision = $CollisionPolygon2D
@onready var flamagor_dial_intro = %Intro
@onready var flamagor_dial_death = %Death
@export var experiencePoint: Node
var health: int = 50
var max_exp_spawn = 20
func _ready() -> void:
anim.play("flamagoridle")
func apply_damage(damage: float) -> void:
health = clamp(health - damage, 0.0, 50.0)
if health >= 1:
anim.play("flamagortransformidle")
elif health <= 0:
#anim.play("flamagordeath") (needs anim)
flamagor_dial_death.playing = true
await get_tree().create_timer(9.0).timeout
flamagor_collision.disabled = true
GlobalVariables.flamagor_dead = true
drop_health()
var number_exp: int = 0
while number_exp <= max_exp_spawn and health <= 0:
drop_experience()
number_exp += 1
queue_free()
func drop_experience() -> void:
var point = load("res://scenes/exp.tscn")
var instance = point.instantiate()
owner.get_parent().add_child(instance)
instance.transform = enemExpSpawnPoint.global_transform
func drop_health() -> void:
var health_point = load("res://scenes/healthpickup.tscn")
var health_instance = health_point.instantiate()
owner.get_parent().add_child(health_instance)
health_instance.transform = enemExpSpawnPoint.global_transform
func _on_animated_sprite_2d_animation_changed() -> void:
flamagor_dial_intro.playing = true
Like I said, I’m not really sure how to begin as I’ve only coded basic enemies thus far. Any help is appreciated, even to get me going the right direction!
Thanks in advance.