rogerg
Member
|
Enemy Tutorials
I think it would be a good idea to have a couple more tutorials which explain how to add enemies to the game and modify their AI and have them play different sounds for different
actions that they do. I played the Esenthel game game so I know that its possible to achieve at least very basic AI where the enemy detects a player and moves towards him.
Hopefully its possible to make the AI more smart by having the enemy run away if its at low health for example.
|
|
12-23-2008 11:45 PM |
|
craksy
Member
|
Re: Enemy Tutorials
adding NPCs is just like adding characters
making the AI is something that require more logical thinking, than knowledge of the engine.... i think :/
its just something like, if the distance between the character, and the enemy is less than X, then begin to attack.
attacking could just be something simple like, keep running towards the character, until in attack range, and then attack.
for more intelligent enemies, it would have to be a bit more advanced of cause...
this is just in theory though... i am no pro!
but i have been making some AI for 2D games, and i guess that the basics are the same?
or you can just google "basic directX AI" or something, and see if you can translate it to esenthel?
|
|
12-24-2008 08:58 AM |
|
Brainache
Member
|
Re: Enemy Tutorials
To have an enemy ( chr class derived object) move towards a player ( or.. anything really...) use this handy function call:
actionMoveTo( position );
position should be a Vec of the location you want the chr to move to
So.. if you wanted a "Terminator AI" that relentlessly moves towards your player, you could call myMonster.actionMoveTo( player.pos() ) during the Main function... ( I personally overide the 'update' method of the chr and do all my ai calls there...)
Now.. if you wanted the monster to run away... you could do something like this:
Vec dir = myMonster.pos() - player.pos();
dir.normalize(); // this will now be a noramlized direction from the mob to the player..
// to run away.. you could do:
Vec destination = myMonster.pos() - ( dir * 20 ); // dest will now be 20 units away from the player
then...
myMonster.actionMoveTo(destination);
note: this is all off the top of my head... dir might be reversed.. if so.. instead of myMonster.pos() - ( dir * 20); you'd do myMonster.pos() + (dir * 20);
the vector part of the AI ( ie: determining direction, postions, etc.. ) is not really engine code, but rather standard 3d vector math... the engine kicks in quit nicely with the 'actionMoveTo' function wich handled the animation, speed, etc... pretty effective all in all...
|
|
12-25-2008 01:47 AM |
|
lucifer1101
Member
|
Re: Enemy Tutorials
that is well explained...
Although i cant use this now i will come back for a reference whe i am up to this point...
|
|
12-25-2008 01:52 AM |
|