First Person Shooter (FPS) gaming engine (alpha version demo)

Updated the demo. Link is still the same: https://babylonjs-fps.com/
Here’s what’s new.

New Monster:
I introduced a new monster that I called CatDemon. Any similarity to existing monsters, living or dead, is purely coincidental. :slight_smile:
It’s my first 3D model made end-to-end and it looks… awesome :smiley:
Seriously, it turned out to be much cooler than I expected.
On the side note, gun models were also made by me for 90%. I downloaded some open-source pack, then heavily edited, rigged and animated by myself, but at least I had some starting geometry there.
What is most important here is that I initiated some sort of code framework in the project to import external monsters.
The CatDemon is quite rich in behavior. It has idle, angry, chasing animations as well as range and melee attacks and dying animation. It also makes funny noises along the way.
For range attack it shoots fireball arcs. The projectile is still physical and slightly loses altitude as it goes, also if you are extremely good at reactions, you may hit projectile with a bullet and dismantle it.
On collision projectiles create small explosion which is purely cosmetical (no splash damage like for rockets and grenades).
For melee attack it tries to bite the target.
CatDemon is beefier compared to existing debugging monsters (400 HP compared to just 80 HP).
It can in-fight with other monsters.
I also added dubugMode for monster instances (shows physical bodies and BabylonJS bounding boxes).

Optimizations:
I heavily optimized ray casting calls.

  • Now rays originate outside of the source mesh instead of its origin. It excludes at least one mesh (potentially heavy) from consideration. Given the number of meshes and frequency of ray casts it gives the highest performance boost.
  • Caching raycast results. If raycast results between same objects are needed multiple times during the same frame, I don’t cast ray again anymore, I use cached result instead.
  • Changed the raycast result processing algorithm from O(n*m) to O(n + m). It can be improved even further up to O(m), but isn’t worth it, because m and n are quite low anyway. This improvement gives barely noticeable effect, since I already use spacial partitioning to minimize interactions only to local areas.

Still looking for further performance improvements. Ray casts give the major slowdown so far according to profiler. Does GPU boosted rays exist?

Bug fixes:

  • Removed obsolete code that caused synced animations to throttle. Now gun animations run smoother.
  • Fixed bugs with life time of throwable projectiles.
  • Fixed some crashes on loading of save files.
  • Fixed crashes when monster is attacked by natural disaster (like triggered explosions) which doesn’t assign a target to the monster.

Back-end:

  • Changed underlying OS on hosting which allowed to install certbot without the pain. Now HTTPS certificates should be updated automatically. HTTPS is crucial for HTTP2.0 which is crucial for multiple resource fetching.
  • Changed the minifying tool. Downloadable package was reduced to 28.6MB (2.7MB for the menu and the rest for the Test Level 0). It also fixed some crashes while loading from save file.

Despite the fact that I solved the problem with free HTTPS updates I still may consider taking the demo down soon, because my Free Tier on AWS is almost expired. Or maybe I will migrate everything to other hosting. Anyway, the demo will be available for at least 3 more weeks from now.

6 Likes