Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(1 edit)

Hey, thanks for having a read through :) 
so without seeing the rest of the code I can see why that could look odd, Its set there simply because there is a cool down on the pursue speed when the enemy reaches the player. Say the enemy reaches you, but you run away, I didn't want the skeleton to immediately chase you constantly. so I just reduce the pursue speed to 0, and then there's a timer that ticks down to say when they can pursue again. 


If the player moves far enough away from the enemy, they will return to their ROAM state. so in that case i wanted to just hard reset it there, so if the player gets close again the enemy would resume at the correct speed. 
 
I could've also temporarily stopped the path action, but I didn't think it would hurt to keep that going and checking the players position for when they can move again. and instead just reduced the speed. 

I should mention i'm still very much learning a lot about code, so I don't always get it right or have the most efficient approach. but i'm getting better.  I've been dabbling on and off with different projects since about 2018,  but i'm a silly artist that hates math, so my progress isn't the fastest.

Again thanks for commenting. 

Ok, cool. When you create a second enemy, like a bat, I recommend you abstract that speed out to the enemy itself, and call a variable on the enemy. That way you can use the same state code for each enemy without having to copy and paste.

Ok, i've done this now, each child objects of the enemy parent just tells it what its own pursue speed is. so it can be unique to each enemy. its working great so far.  thanks for the tip! 

(+1)

You're welcome!