Creating SMART enemies from scratch! | Devlog

preview_player
Показать описание
Play the free demo on Steam!

Join my Discord!

Veih is an amazing artist, check out their kofi!

I teach game development/programming courses on Udemy, check them out if you're interested!

Lua and Love2D:

C# and MonoGame:

Music: Lake Theme from Pokemon DPP
Рекомендации по теме
Комментарии
Автор

I'll admit it - I didn't know what a raycast was when I made this video.

Challacade
Автор

One cool option is also breadcrumbs! You spawn small invisible objects behind the player that disappear over time and you make the enemies go in that direction...

Filipinjo
Автор

very deceptively simple and performant way that's actually pretty realistic is for the enemy to move not towards the player, but towards the last spot they saw the player at. It's also cool because it introduces stealth elements where you CAN lose the enemy if you find a place to hide once line of sight is broken, but if they're following you closely they'll probably be able to see you after they reach the point.

If you want to make it even better, you can make them go into a "search" state where they wander around randomly for a bit if they reach the point but still can't see you. If you want to get more complicated but make them even smarter, weight the random directions away from the direction they were just moving so they search an where you probably are and don't backtrack. Then put a timer on the search state so they go back to idle if they can't find you after a few seconds. That's how enemies in stealth games usually behave anyway.

hotworlds
Автор

I was just watching a talk by Rami Ismail and he mentioned how you should fake smart AI instead of making actual smart AI. Although your set up so far seems more about pathfinding rather than making "smart" enemies, so you haven't dug deep into AI behavior yet. But it's something to consider. There was also a study done for one of the Halo games where players felt enemies with the same AI but dealt more damage were "smarter" even though the behavior was identical

joestromo
Автор

I'm so glad to finally be at a point where I can watch a short video like this and know exactly what I need to do to implement it into my game. This definitely beats having to watch 2 hr tutorials that have to explain each and every step.

gamingoverlord
Автор

Something which might improve the performance is to calculate the line of sight by checking if the line intersects with any of the collision geometry inside the rectangle formed by the end-points of the line of sight. This way you don’t have to do a bunch of collision checkes iteratively over the line’s length, but instead check only once per line. Not sure how your collision is set up, but this might benefit the performance, especially if you have to recalculate line of sight for every tile for enemy pathfinding too

sahandwagemakers
Автор

Great insight! Enemy AI is a surprisingly nuanced topic and it's great you got it to work well!

wigglebot
Автор

Be careful comparing lists against lists. It can get very performance heavy. Usually A* only checks one cell at the enemy position at a time. Then uses neighbour checks. You get neighbours by carrying the grid with you. It's a whole thing but imo well worth the performance increase.

michaelhymand
Автор

Was going to say something similar to the breadcrumb idea, have the enemy store a sequence of last known player positions within it's detection radius, then have enemies pursue the latest position it still has LOS of. The breadcrumb is good because it only stores one copy of those positions though.
One note about the breadcrumb idea is to only drop them if the player is within an enemy's detection radius to save performance.
Another thing to consider maybe is having the enemy give up if it reaches the last position that was within it's detection radius and it still doesn't see the player. Then at that point it can choose a random direction to pursue based on the trajectory of the player's previous path. Say like within a 30 degree cone of the direction the enemy is already traveling. This way the enemy doesn't know where the player is, but it still goes in a pretty good guess of a direction.

mjcarlsbad
Автор

I liked that it is more like a "pseudo"" code rather than actually showing the coding itself making it usable throughout different engines.

reigndevelops
Автор

Nice use of a bi-directional path finding ^_^, as you already have states for your enemies, it would be fun to see some "Elite" enemies order their minions around with "regroup" "swarm" "hold" "attack" actions etc. also would be fun to see if the slimes could coordinate a pincer attack or do a "wall tackle"

naukowiec
Автор

Pretty solid solution. I thought about maybe pursuing the last known location, but after thinking about it, I could see that having issues in itself.

haydenmarlowe
Автор

Something that could really add to the enemy system is different enemies pursuing the player in different ways. Maybe something small and dumb like the slime will just go at the player, but maybe those projectile launching guys from the cloud area back away from the player, and can even fly off the stage. a ranged enemy wouldnt want to go towards the player, it would want to be at a range. I think it could add some depth where different enemies instead circle, flank, or kinda bait the player instead of just going straight at them.

phrog
Автор

Bro, take care of your game's performance, to LOS, use a raycast, and to let the enemy chase the player even when he loses the LOS, make the enemy go to the last position when player was sighted, or use a AStar algorithm to pathfinding the closest path beetwen player and enemy

guustavols
Автор

you have an amazing knack for explaining things clearly and effectively! ️

YagamoReba
Автор

Increasing enemy AI is another way of having a harder difficulty without it feeling artificial.
Just increasing attack power from enemy attacks can only do so much.

stephen
Автор

Love the content! Always inspires me to work harder at game dev and making videos :)

mz_eth
Автор

A momentum-based pursuit approach (both linear and angular) would be interesting to try to make work. It has a little more persistence than stop-at-last-location, but it also allows you an opportunity to cleverly hide.

Or, base some enemies on logic of “scent” instead of “sight”. Could be a fun mix.

the-rudolph
Автор

i love the pokemon mystery dungeon music at the start. also nice video, the games come a long way.

picklepie
Автор

I already really like the game!!!! Keep on the great work, man! Much respect .

ziadhassan
welcome to shbcf.ru