I am also not good game AI programmer but here (also with non AI):
1. Enum, you can name it
enum abc{
a,
b = 2,
c
}
But if you still want to use that way, use it like constant variable, I mean name it with UPPER_CASE
.
enum { A, B, C }
2. Use type hints, make it more easy to read and auto complete
var some_node: Node2D
var rng: RandomNumberGenerator = RandomNumberGenerator.new()
3. Private variable/function name with _ at start
var _health: int = 25
func _is_dead() -> bool:
return _health < 0
4. RandomNumberGenerator
, I don't know why you store it in 3 difference variables. Just 1 should be enough in this case. Or even just don't need it, just use global scope rand_range(). Like what you already did, randomize()
.
5. Field of View, make the AI not somewhat blind(where they can some what only see what only straight in front of them). For starter, just use a lot of ray cast is already ok.
6. Stage Machine. Yes, you already use it with forward
, rotate
, stop
things, but I mean such idle
, wander
, chase
, meelee_attack
, range_attack
, flee
, search
and such with proper state transition (some state can't directly move to another state without move to other state first).