We want to write two modules that can be used for NPCs:
-
A Finite State Machine that will process incoming events and then make decisions about the NPC’s behavior.
-
A Steering Engine that will do all the math for creating various steering behaviors such as flocking, fleeing, pursuit, etc.
Our game environment calls for up to 6 or so NPC teammates for the player, and then hopefully between 10-20 NPC prey items that will act as a herd and be targeted by the player and their team. So we’re talking about around 25 avatars + player that are active in the level and having their positions and animations calculated and played back.
That’s in addition to the overall environment, which includes the Nature Pack grass.
The question is, will either of these engines benefit from being written as a C++ plugin? I understand already that C++ runs about 2x faster than JavaScript. For this application, and the number of agents we want to be active, is that difference significant? Or is it not worth the bother to do it in C++ (we have the programming capacity to do either)?
Also, I never did fully understand the answer about calling a C++ plugin from JavaScript. Is it or isn’t it possible? If not, do you have to call the pluging from C# and then the C# from JavaScript? What’s the performance hit on that?
Thanks,
Steve