Palaxe
Member
|
Npc Shooting Fireball at Player
Hi Everyone,
I been working in RPG and have a pretty good handle on it now. I'm to the point where I would like to have my hydra spit fireballs at me.
I been looking everywhere for a reference how this is done.
Would someone be so kind as to share a link or give me a hint where I can find how this is done.
Thanks
|
|
12-04-2013 06:28 PM |
|
Fex
Gold Supporter
|
RE: Npc Shooting Fireball at Player
Its done the same way the player would spit fireballs.
Basically each NPC class will have a Memc<Fireballs> fireballs; member that your update and render each frame.
Look at how the fireballs are done in Ineisis (your single player RPG should be even easier, you only need to look at the client code, masically your store each projectile in a memc and update their positions each frame). Or in Esenthel RPG2.
Just make the inital pos the NPC pos, make initial dir vec Npc.pos - Plr.pos, or if you want to be fancy you can fire the ball so that it leads the player using something like:
(Npc.pos - Plr.pos) + Plr.movevecnormalized*Dist(Plr.pos, NPC.pos)/fltSpeedofProjectileinmetersPerSecond
If you want the AI to appear smarter use a ray/physhit to make sure the NPC has line of sight before firing at the player.
|
|
12-04-2013 07:09 PM |
|
Palaxe
Member
|
RE: Npc Shooting Fireball at Player
(12-04-2013 07:09 PM)Fex Wrote: Its done the same way the player would spit fireballs.
Basically each NPC class will have a Memc<Fireballs> fireballs; member that your update and render each frame.
Look at how the fireballs are done in Ineisis (your single player RPG should be even easier, you only need to look at the client code, masically your store each projectile in a memc and update their positions each frame). Or in Esenthel RPG2.
Just make the inital pos the NPC pos, make initial dir vec Npc.pos - Plr.pos, or if you want to be fancy you can fire the ball so that it leads the player using something like:
(Npc.pos - Plr.pos) + Plr.movevecnormalized*Dist(Plr.pos, NPC.pos)/fltSpeedofProjectileinmetersPerSecond
If you want the AI to appear smarter use a ray/physhit to make sure the NPC has line of sight before firing at the player.
Sweet, Thank you very much. This is a good place for me to start
|
|
12-04-2013 07:24 PM |
|