Creating SMART enemies from scratch! | Devlog

Creating SMART enemies from scratch! | Devlog

Challacade

8 месяцев назад

276,911 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@Challacade
@Challacade - 27.01.2024 03:48

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

Ответить
@stysner4580
@stysner4580 - 31.01.2024 19:03

I think it's way easier just having a "last tile I saw the player" as a target, going there, then if there is no LOS from that tile to the player get "confused" and randomly search, or go back to the default position/last patrol point.

It makes more sense from a real world perspective and is way better for performance (no need to recalculate an entire LOS grid).

Ответить
@BiriOboreta
@BiriOboreta - 30.01.2024 22:19

mans created a nextbot 💀

Ответить
@vyldim3401
@vyldim3401 - 29.01.2024 22:48

Would reccomend checking out the A* pathfinding algorithm. I'll have to assume that the tiled LOS checking is kinda expensive.

Ответить
@ethancox2025
@ethancox2025 - 29.01.2024 16:12

Really impressed here at the creativity in your solution to the problem. I wouldn't change it except for performance should that become an issue. Beauty of indie dev games is this type of uniqueness

Ответить
@maxontheroad4919
@maxontheroad4919 - 29.01.2024 14:22

Could you please share the code?

Ответить
@TheRedCap30
@TheRedCap30 - 28.01.2024 04:29

You could have a LOS timer where after a second or two the AI stops following the player if they are not in LOS anymore

Ответить
@gastontzartos1928
@gastontzartos1928 - 27.01.2024 17:59

what is this game maker??? what engine is it? unity? where do i get it?

Ответить
@captaincyberspace4370
@captaincyberspace4370 - 24.01.2024 22:06

What I used for my (never released game) is what I called "decaying waypoints". The player left a waypoint behind, every 0.n seconds. And those points got removed after a little while.
Enemies followed those waypoints of course, when they where in sight for them. After a while those points just vanished. So the player is always able to escape, it felt somewhat natural and it was really simple to implement and use.

Ответить
@PurpleSlime-ww9fe
@PurpleSlime-ww9fe - 21.01.2024 17:20

If you can , make it for mobile please

Ответить
@theaztrax
@theaztrax - 21.01.2024 08:05

These videos are so helpful for when I’m trying to problem solve. Legend 🤙

Ответить
@PeterMilko
@PeterMilko - 20.01.2024 21:31

I did line of sight using a raycast. (Unity) Simpler suggestion for following player is to just to have the player generate an invisible trail the enemy can follow if sight is lost. It will be more performant than what you made. Come look at the game im making :)

Ответить
@historymaker118
@historymaker118 - 19.01.2024 23:08

That was a really fascinating video, I'm very interested in the way you tackled the enemy navigation/pathfinding to work in your game. It's a very good solution to the problem, and I especially like how you were able to use it to also create idle patrol movement too. Great game art as well btw, love your style!

Ответить
@polandsilver3419
@polandsilver3419 - 18.01.2024 12:27

Could't you just add another variables for x and y of player that always changes to were player is if enemy sees the player and enemy goes just to these second cordinates? If player dissapeard behind the corner, enemy goes where it saw the player for the last time

Ответить
@standardsteve147
@standardsteve147 - 17.01.2024 09:01

you can add multiple LOS checkers so that if the LOS is hitting the player the LOS is true

NOTE: If you want to make the enemy more difficult add multiple LOS behind the enemy to and increasing the range of LOS lines

Ответить
@lapridagaspar
@lapridagaspar - 17.01.2024 04:26

I do LOS with a raycast from the enemy to the player. Add a layer mask for obstacles and if hit.collider!=null it means there is an obstacle in between, so LOS=false, else, LOS=true.

Ответить
@dynaheart
@dynaheart - 16.01.2024 23:15

fantastic solution! I'm taking notes to use some of this on future projects :)

Ответить
@shiromeownyaka
@shiromeownyaka - 16.01.2024 03:43

Can you make a tutorial that's based on these systems?

Ответить
@anon_y_mousse
@anon_y_mousse - 15.01.2024 23:53

I don't know if you hand draw your levels or generate them, but you can generate path nodes either way and just have the enemies follow the nearest path that they last saw you along until they get tired of chasing you, as in via a time limit to their agitation. Basically, LoS would be the key metric, but once that's lost they could follow path nodes closest to where they last saw you and scan their radius while the timer counts down, unless LoS is picked back up, and then the timer restarts. If you don't know how to generate path nodes, there's several videos showing various techniques for it, and there might still be one that explains Unreal's automatic path node generator.

Ответить
@RevymOfficial
@RevymOfficial - 15.01.2024 06:11

Awesome devlog! This game is beautiful and looking great so far 😊

Ответить
@raynesz2903
@raynesz2903 - 11.01.2024 13:39

Pathfinding isnt an uncommon concept in video games. The A* algorithm has been used for years and since its well suitable for gridbased environments it may be well suited for your game. Adjust the size and density of the grid cells to balance performance and enemy movement

Ответить
@GenericInternetter
@GenericInternetter - 10.01.2024 12:27

Make the NPC chase a point that represents the player's last known location.
Update that location every time the line of sight check to the player succeeds.
If the enemy reaches the last known location and the line of sight check to the player fails, then the NPC gives up and goes back to idle.

This way when the player runs around a corner, the enemy will go to that corner to look for the player.
For the player to escape, they'd need to quickly get out of line of sight of that corner before the enemy reaches it.

A more complex but more effective addition to this would be for the player's movement direction to be added to the last known location object.
When the enemy reaches the last known location, it could continue moving in the player's last known direction.

This would force the player to have to quickly go around multiple corners to avoid the enemy finding them.
This is more realistic and somewhat on par with human behaviour.

Ответить
@etrex5272
@etrex5272 - 10.01.2024 01:37

While im kind of impressed, at the same time im not. You should always try to make things as simple as possible or else you just end up creating unbearable overhead. If I used your system in my game with 1000 enemies in it, it would probably run at 5 fps not 400. Just do move to last seen player pos, simple search and back to idle or chase. And LOS could just be a trigger box collider checking for obstacles by tag. It would likely be 50 times more performant.

Ответить
@avraham967
@avraham967 - 07.01.2024 21:35

i wish you would teach us the code itself too. it would be amaing to learn how to code those stuff

Ответить
@mojojojo6535
@mojojojo6535 - 06.01.2024 06:35

Ik im a bit late but could you make it so you could "bait" the enemy so the enemy can guess a direction. You could make a aggro level where the more aggro the more they will chase even if they cant see you. Some enemies could be territorial and some could be evil maniacs. Its always fun to think about why an enemy is attacking the player rather than enemy is enemy . Well theres my mind

Ответить
@djblast101
@djblast101 - 03.01.2024 15:43

A simpler solution with less processing for recalculating tile data I would say as the player is being pursue and by enemy they will periodically drop bread 🍞 crumbs.

These are just invisible vector or specific tile. So say you turn a corner if you dropped a breadcrumb the enemy will look to the last breadcrumb go to that and then see if the enemy is within LOS.

Breadcrumb is a awesome solution. The tricky part is what is too frequent and what is not frequent enough for dropping breadcrumb. You could adjust depending on the enemy like part of their intellectual stat.

Ответить
@JK96CZ
@JK96CZ - 01.01.2024 23:54

As a very beginner this may be question bit off... but I wonder how much is this resource intensive? Since you check every frame for that LOS and have lots of points which may be on / off very quickly.

Ответить
@voidipoyo
@voidipoyo - 31.12.2023 13:53

If the player is suddenly not in los, the enemy will move to the last location of player in los

Ответить
@D_To_The_J
@D_To_The_J - 27.12.2023 08:10

Haven't tried it myself but you could potentially have the enemy go to the last known position of the player. IE the position player position from whuch it had its last line of sight hit. That would be similar to how a real life situation would occur if you lost sight of something. This should in theory be less impactful from s performance stand point also since its just caching a position you already calculated.

Ответить
@Gooby-Goobers-
@Gooby-Goobers- - 27.12.2023 04:21

why not just make a buffer time? So when LOS is false, timer starts counting down, and the enemy will only stop chasing when the timer is or below 0.

Ответить
@nicolasdelfino1
@nicolasdelfino1 - 25.12.2023 17:04

Did you consider giving the enemy a time based window where it could run towards the direction it last had LOS of the player? That way it would work as an instinct type of functionality that you could abort if the enemy fails to renew the LOS

Ответить
@DanielPBullis
@DanielPBullis - 23.12.2023 00:02

Another idea would be to keep track of the position where LOS was last true, then have the enemy move to that position if LOS ever goes false. So if the player goes behind the wall enemy will go to the place where the player disappeared. From there, it might be able to regain LOS unless the player goes behind another obstacle, in which case, the enemy goes back to idle, essentially having “lost track” of the player. 😊

Ответить
@gabriellacunza1585
@gabriellacunza1585 - 21.12.2023 18:38

idk if its a good option but i think it would have been better to make the monster remember the last place that has seen the player, is it a good idea?

Ответить
@k1ng_chicken
@k1ng_chicken - 21.12.2023 11:00

That music sound veeeery familiar, what is it?

Ответить
@luizhenriqueromanholferrei6610
@luizhenriqueromanholferrei6610 - 19.12.2023 20:51

just make a list of the player last positions, if the enemy LOS is false then it will try to go to the last player position which has a true LOS

Ответить
@EmberCitrine
@EmberCitrine - 17.12.2023 20:00

I think I would give the enemy a searching state. when it first enters this state, it continues towards where it last saw you, then goes a short direction in your last known velocity. if it hasn't found you by this point, it wanders for a bit then reenters idle state. having your own los data on the player seems useful though.

Ответить
@okbutwhatif9905
@okbutwhatif9905 - 16.12.2023 18:06

This is the second game I'm seeing that looks the same today. I'm sure it's good but it doesn't seem new or revolutionary.
Best intentions in mind here.

Ответить
@gendalfgray7889
@gendalfgray7889 - 15.12.2023 20:01

Congratulation, you invented navigation and sight perception!

Ответить
@mariovide0z
@mariovide0z - 15.12.2023 18:28

you should make the enemies have a raycasting circle around them (that’s small) and if it detects an object/wall it will go the other direction depending on the situation, tree = right/left (random) wall = opposite direction of wall.

Ответить
@lazylenni1017
@lazylenni1017 - 15.12.2023 05:30

Which software do you use to create sprites?

Ответить
@TuriGamer
@TuriGamer - 14.12.2023 20:57

Roll buttons truly never fail to make a game worse

Ответить
@samual_not_samuel
@samual_not_samuel - 13.12.2023 22:01

Give the enemy a Vector4 variable called something like chasePoint. As long as the enemy has line of sight of the player update the chasePoint so the first 2 floats equals the players current position, and the last 2 floats equals the players current direction. Should the enemy lose sight of the player they can use the chasePoint to move to the players last position, then they can search for the player by moving in the last direction they saw the player go.

Ответить
@invasivereveries
@invasivereveries - 13.12.2023 12:20

The enemy could walk to the last tile in which line of sight was true. Once it reaches there, if the player is still in pursue range and LOS is true, it resumes pursuing, otherwise it goes back to idle. I think this approach may not always work as intended and is easily picked up by the player but performance wise, it might be a better option.

Ответить
@Gatitasecsii
@Gatitasecsii - 12.12.2023 13:12

Nah the AI is definitely easier than the design.
You can tell by how generic your game looks.

Ответить
@MrKulaklik
@MrKulaklik - 11.12.2023 17:04

Vampire survivor just says fuck it my enemies are ghosts

Ответить
@etzbetz
@etzbetz - 10.12.2023 11:34

My first thought about the chasing without los had been, that the enemy could walk to the last point at which he had seen you. At least in the video he often would have found you at your new position then. But I think your system is better eventually, even though to be out seemed like it would be quite processing intensive eventually?

Ответить
@fritsbits
@fritsbits - 05.12.2023 02:55

Did this impact your performance at all? Seems like a lot to track.

Ответить
@goldencookie5456
@goldencookie5456 - 04.12.2023 03:54

A lot of people have been suggesting to make the enemy move towards the last seen location of the player, but as you have said, with this system, if the player turns multiple corners, the enemy wouldn't be able to follow the player.

So I thought of an extension of this system. It's actually probably wayyyy more performance intensive than your solution and probably more complicating, so it's totally pointless and useless, but I will share it anyways.

Instead of the enemy simply going towards the last seen location of the player, it also creates a checkpoint at that location. The checkpoint itself performs LOS checks for the player, and when the player get's out of the checkpoint's sight, it creates another checkpoint at the next last seen location of the player. In this way, a trail of checkpoints are created for the enemy to follow.

Idk how to explain some of the details I thought of, so I just made ChatGPT summarize the system:

"-When an enemy has a direct line of sight to the player, it actively pursues them.
-If the player goes out of sight, such as by turning a corner, the enemy marks the last seen location with an invisible checkpoint.

-These checkpoints are not merely static markers; they actively perform line of sight checks to detect the player.
-If the player goes out of the checkpoint's line of sight, it triggers the creation of a new checkpoint at this new location where the player was last visible.
-This results in a sequence or trail of checkpoints.

-The enemy follows this trail of checkpoints to track the player's movements.
-This allows the enemy to continue the pursuit even when the player has made multiple turns or maneuvers that break the direct line of sight.

Checkpoints are destroyed in three scenarios:
-When the enemy reaches a checkpoint.
-When the enemy resumes direct chase after spotting the player again.
-When the enemy stops the chase altogether.

-Enemies only follow checkpoints when they are in an active chase state, having seen the player themselves.
-The enemy always follows the most recent checkpoint within its field of view.

The system is designed to enable the enemy to pursue the player over a complex path with multiple turns and corners, not just to the last point where the player was seen"

This is overall probably extremely performance intensive cuz of all the line of sight checks, and makes things way more complicated than it needs to be. But maybe this can help spark a new idea or something? What do you think?

Edit: Also forgot to mention that the chase state is either determined by the amount of time it has spent chasing, or the overall distance between the player and the enemy. The checkpoints themselves don't play a role in it. The checkpoints are simply for following and tracking.

Ответить