Looking for sources on Self Surviving AI for NPC

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

New to development and I know I am jumping way off the deep end, however looking for sources or examples of NPC AI where NPC has 3 attributes HP, Food and Water. Subject to level of each AI will source to fix their need. E.G eat berries/kill chicken, find water etc. does something like this exists in Godot?

:bust_in_silhouette: Reply From: gamedevshirious

Me too not sure how to implement, but something you can try:

Create a Timer to the NPC say 5 secs,
every time the timer times out, the NPC will check for its unmet attributes (you may prioritise or randomise) and select the unmet need.

you can create an array/dictionary of Vectors where each source is

when finalized you can write below code for movement,

func _process(delta):
    var speed = 10
    if source.position.x > position.x :
	    position.x += speed * delta
    if source.position.x < position.x :
	    position.x -= speed * delta
    if source.position.y > position.y :
	    position.y += speed * delta
    if source.position.y < position.y :
	    position.y -= speed * delta

Hope it helps. Let me know if you have more questions.

Thank you for your input and especially the movement code, I guess I have a lot of research ahead of me.

LAzyAusGamer | 2021-08-22 16:07

I suggest narrowing down your question by explaining what exactly your NPC or what type your came is say 2D Platformer, 3D, Top Down etc. the code words for top down.

gamedevshirious | 2021-08-22 16:13

:bust_in_silhouette: Reply From: sash-rc

Learn basic concepts of Behavior Tree pattern.
Then, implement your own or use some of 3rd party addons for Godot.