So I have been trying to practice making AI without any good result, one of them is enemies/npcs walking around random place. I have tried to find on youtube or forum but can’t see any that close to what I tried to do.
This is what I got so far, not perfect and npcs stop felt awkward too
Also when they move, they pop up and down, not easy to see and I use shake extension for that. if anyone have better solution, pls help with that too :P.
I also tried pathfinding but it felt weird, the variable doesn’t start to randomize at all like if it 4 it stuck at 4. I also don’t know how to make them stop on certain distant, I thought change variable will do but apparently not
There’s an extension actually called “Make object travel to random positions” which does just that. It uses pathfinding and it’s supe easy to use. You can use an object timer for the NPCs that resets after a random value and moves them to a new random position.
Yeah I have try the extension before but without an example it kinda act weirdly. but yeah seem like it work alright base on your setup, could you help me with the stopping? I want them to stop either to stand there or do something, but I dont know how to make them stop and stand still
what I did is “if timer of NPC >= random number → random variable” and if it land on specific one, wait for random X time and do timer again but it not working (also I put OR on [the beginning of the scene} and have it with [if variable = 0] as a condition to start clock again, dont know if it good idea. Sorry for bothering I tend to over thinking to dumb solution
It really worked like how I wanted, god you are my saver, thank you so much .
I didn’t even think about this, make them move on their own spot to trigger the “reached destination” condition. Also could I ask why you put the random variable at the spot where the timer start? I cant see the different yet, also I thought make them move on their spot without the [for each object] would confuse them?
Oh yeah this dude, I have been watching this video over and over again and dissecting it, sucked cuz I have square brain lol, I always confuse like is the circle under enemies feet, like how that work and how to do it in gdev, is there a magical thingy I didn’t know? I was planning to watch it again for one of my project after this.
oh I mean like cuz they in a group, wouldn’t they got confused cuz we don’t specified which spot is which, like I thought A would be confused and try to move to B spot, you know?
The “at the beginning of scene” makes all its sub-events run only once when the scene is loaded. So you probably need to put the for each event as a standalone event.
After hours of playing around with it I could never get the timer to work correctly. I was trying to get the enemy to move to a random location, stop for a couple seconds then repeat the move action. I was able to get it to work for the first enemy but none of the newly spawned enemies have the effect, even with “for each instance”. I can deal without the timer if need be however.
Now I come to a new issue however, suggestions on how to contain all of the spawned enemies within a certain area?
With the current random move action, it doesnt take them long to get pretty far away from their spawn point.