ai advice

Blitz3D Forums/Blitz3D Programming/ai advice

Ruz(Posted 2004) [#1]
Just thinking about putting an enemy in my demo level(3d 3rd person)
Whats the way to go on this.
I want some simple ai to start with.

So for example if I get near him he swipes at me , then retreats. I could use entity distance for this.

I not really sure what else would be cool that is not too complex.
The idea here is to get a simple thing going
ie advance retreat, turn to face the player.
path nodes ar a bit too much for me to handle right now.
I have some butterflies to put in my level too, so i could do the same for them.
I don't nmeed solid code right now, just suggestions as the right way to go.


darklordz(Posted 2004) [#2]
EntityRadius Cmd should help. If you the main char comes within a certain radius you could let the enimy swite @ you or run towards you and swipe @ you and then run away...


jfk EO-11110(Posted 2004) [#3]
I'd use a combination. Use EntityDistance. Then, if close enough, use EntityVisible, then, if _potentially_ visible, use the in-field-of-view function from the code archives to check if the enemy is looking away from you. You can also combine this with the amplitude of your footstep sounds, depending on surface, so he would turn araound and attack when your loud, or wouldn't notice anything when you are sneakin silently - a bit like in splinter cell.

If you want to animate your enemy, the easiest way is to let him patrol along waypoints.

Later you could add some behaviour like "enemy hides when you aim on him with your gun" or "enemy attacks when you run out of ammo" etc.


Gabriel(Posted 2004) [#4]
Have you read Mordy's article on Finite State Nachines?

http://www.blitzcoder.com/cgi-bin/articles/show_article.pl?f=morduun07112003153313.html

It's a generic introduction to the subject, but - for me anyway - it gives you the grounding you need to make everything straightforward and neat before you start any code.


Ruz(Posted 2004) [#5]
cool, thanks guys. I will look in to this afternoon.
Its an interesting topic and If I get past my inital apprehension on this I will feel much better.
I am sure I spend a few days on it I will cobbble something together.
The hard part is deciding exatly what you want your enemy to do.


Ruz(Posted 2004) [#6]
I made some progress. I have it now so that when the enemy sees me, he runs towards me and when he gets wihthin 5 untis he stops, goes in to idle/still mode . When I run off he starts the run anaimation again, but smoothly using the tween thingy.
the hard part seemed to be getting the animations to work correctly.

Will post some code later and you can perhaps advise me how to improve it.
I am nor sure how to do timed stuff.like after staying still for say 10 secs how can I get him to change to a different idle animation.

I may now put in a single way point as the enemies homebase, so when he can't see me he returns there and idles about.