WeaponsTest - Work in progress asset handling and scripting of game weapons

I have been wanting to add this for a while now to the work in progress forum group. Some time ago I had seen a lot of support questions mainly on handling different aspects of weapons. What particularly caught my eye was statements like “You know like Unity does their weapons” or “Unity is so much easier to do this”. My basic take on this is no way! Gaming engines are gaming engines and they all use the same terminology and methods. The programming language is different but the baseline concepts are not. I think one of the bonuses that gets overlooked with Playcanvas is the fact that it is browser based. You can play a game on any device that supports a web browser. No need to compile something and download drivers to run a memory intensive game.

What I proceeded to do is to find a good spot on Youtube to go through a few Unity game tutorials and port over the methods to PC. Which went very well. Here are the two videos that I modeled my scripts around. I will list the author and titles and you can just search them on YouTube.

Brackeys - Shooting with Raycasts - Unity Tutorial

Brackeys - Weapon Switching - Unity Tutorial

The link to my WeaponsTest project is here: PlayCanvas 3D HTML5 Game Engine

The link to just play it is here:

Here are the controls currently available:

[W] - Move forward

[S] - Move backward

[A] - Strafe left

[D] - Strafe right

[H] - Toggle crosshairs on/off

[R] - Reload

[Space] - Jump

Left Mouse Button - Fire

Right Mouse Button - Either align by sights or pull up a scope.

Mouse Scroll Wheel - Cycle through weapons

Number Keys - 1-9 Usable to select weapons by key. Will grow and shrink automatically by the number of weapons in the player’s assets.

I have also added a very basic weapons management system which keeps track per weapon of magazine size and spent ammo count. This could be a lot better but it will keep track of each weapon as they are used.

There are still things that I wish to add to this work in progress. My methods used may not be the best but hoping it will spark some ideas for everyone.

Hope this is helpful to the community of Playcanvas developers. I really hope to encourage users of Playcanvas to find videos from other engines and develop the skills to do your own conversions to this wonderful platform. Stay tuned for updates and feel free to make suggestions. I may not be able to implement things very quickly but will do my best.