Enemy Seek/Flee Logic Problem

I have an object named ‘Enemy’. Enemy is set up to Seek another object named ‘Player’. Player can shoot projectiles at Enemy and Enemy has a property to keep count of how many times he’s been hit. Enemy dies after 3 hits.

All good so far.

I want Enemy to switch to Flee when he gets hit with a projectile, and continue to Flee for a certain Delay period before he switches back to Seeking.

I’m not sure how to set this up. Can anyone help?

Look into set state actuator, so you can have the property hit a point and then switch to another state… I’ll add a .blend when I finish

edit: here it is
press space bar 5 times and he will start fleeing briefly and then he will attack again (you can pick it apart and figure out how to make this work for your game) btw this is in blender 2.79
FleeSeek.blend (466.2 KB)

Thanks for your help. I realized I needed to use states after I posted. I’ll study your blend file.

Why did you put an Edit Object > Add Object actuator on the attacking cube?

I took it off and it doesn’t seem to make any difference.

Oops, I thought I did that, but it worked so I didn’t change it- it should be edit object>track. lol, I hope my .blend helped, good luck with your game, I can’t wait to see more about it.

Yes your blend helped a lot.

I’ll start a thread for my game development, but I don’t know if this project will ever be anything epic. More of a learning exercise.

1 Like