
Build single and multiplayer games with Babylon.js in JavaScript, from vehicle-based scenes and tank combat to physics, particles, and multiple cameras, then deploy to Heroku with realtime client-server play.
Hi, Please Note That Different Code Files Are Available Per Section, So That You Work With Me Step By Step.
After You Extract The Folder Go To SinglePlayer/js/Lectuer-Codes, Where You Will Find Code Files For Each Section
Set up your Babylon.js development environment for single and multiplayer games by choosing a code editor, creating a JavaScript project, installing Python HTTP server, and loading the Babylon.js max file.
Create your first Babylon.js scene by setting up a canvas, engine, and scene; add a sphere, ground, and point light, configure a camera, and render in a loop.
Explore how lights, colors, materials, and textures shape a Babylon.js scene, including ambient, diffuse, and specular colors, real-time reflections, textures, and bump maps.
Create a green ambient scene with a mirror plane in Babylon.js, using a mirror material with reflective and dynamic textures, and adjust the plane’s normal and distance to control reflection.
Explore how to apply diverse materials to objects in Babylon.js, including ambient, diffuse, specular, emissive properties, textures, reflection textures, alpha, normal maps, and video textures.
Build terrain from a height map with grass texture, then enable a gravity-enabled, colliding camera and directional lighting for transitions to new levels.
Enable WASD movement and pointer lock to rotate freely while keeping the cursor inside the game, using cross-browser event handling in a Babylon.js scene.
Create a tank as a box mesh in Babylon.js with a red material above the ground. Implement a follow camera with moveWithCollision to track it.
Move a tank using the WASD keys in Babylon.js, implementing a front vector and alpha-based rotation to navigate while updating speed, position, and keyboard input handling.
Learn to import animated models into a Babylon.js game by loading the dude, inspecting mesh names and skeletons in a sandbox, and configuring a looping animation.
Build a Babylon.js scene where a dude follows the tank by computing the direction, normalizing it, and moving toward the tank within a set distance.
Create a JavaScript class to clone and manage multiple dudes, implementing a move function with mesh positions and collisions, and instantiate multiple instances in preparation for the next video.
Clone a mesh with all its children and skeletons, assign a unique id, and place clones at random x and z positions for multiplayer testing.
Learn how to implement a bounding box for collision detection in Babylon.js to curb per-part checks, by computing min/max vertex coordinates in model space and applying transforms for correct scaling.
Implement per-dude bounding boxes by computing model-space dimensions once with a static class variable, then update each bounding box from child positions and current scaling in Babylon.js.
implement and refine bounding boxes in a babylon.js scene by making them transparent, enabling collisions, syncing their positions to the model, and debugging alignment to prevent overlaps.
Explore how Babylon.js integrates external physics libraries to simulate real-time game physics, including collisions, gravity, bouncing, projectile motion, and explosions, using impostors to simplify and optimize calculations.
Explore how forces and impulses affect objects in a Babylon.js scene, showing how mass governs acceleration and impulse changes velocity, including translational and rotational torque effects.
Explore advanced physics features in Babylon.js: explosions, a gravitational field, and collision callbacks, with debug visuals and timing controls.
Enable scene physics, fire cannonballs from the tank with impulse forces and the front vector, and dispose balls after a timeout to optimize memory.
Explore Babylon.js actions, triggers, and the action manager to respond to events like pointer over, intersections, and more, using actions such as set value, interpolate value, and execute code.
Learn to fire laser beams with ray casting in Babylon.js, defining origin and direction, rendering visible rays, and detecting intersections with scene meshes.
Explore particle systems in Babylon.js to simulate blood effects when hit, using textures and emission centers, and colors, lifetimes, gravity, and start/stop controls.
Create a static particle system to emit blood from the hit point using a texture and red color with gravity direction, triggered on hit and with health management.
Modify the cannonballs to directly kill, and implement a larger blood particle burst in Babylon.js, adjusting emitter center, directions, and imagery while fixing disposal logic.
Discover how the assets manager loads scenes, models, textures, and sounds in a Babylon.js game, with progress callbacks and a render only after all assets are loaded.
Load the dude model with the assets manager by configuring a mesh task, handling on success to call the imported function with loaded meshes, particle systems, and skeletons.
Load canon, laser, and dying sounds into your Babylon.js scene using the assets manager, then play them on events like firing and dying with loop controls.
Develop a realistic first-person shooter feel by adding a photo camera to follow the hero and a separate follow camera with keyboard switches.
Learn to implement a follow camera for the hero dude and control movement with w/s keys, updating the front vector and alpha rotation to keep the camera aligned.
Use a downward ray to measure ground height under the character. Then update the character and bounding box position for uneven terrain in Babylon.js.
Learn how the babylon.js free camera uses an ellipsoid for collision checks with scene objects, and how radius and offset set camera height and position.
Explore implementing a first-person free camera in Babylon.js, handling ground physics and collisions, and switching between free and follow cameras while syncing position and view direction.
Create a movable crosshair as a transparent gun-aim texture attached to the free camera, fire bullets from the camera, and adjust the crosshair and canvas for clear rendering.
Implement gun firing in a Babylon.js WebGL game by loading a gun sound, emitting bullets from the screen center on pointer down, and wiring the fire gun logic.
Learn to render a scene with multiple viewports in Babylon.js by attaching different cameras to each viewport, enabling a split-screen display and managing an array of active cameras.
Use layer masks on meshes and cameras to control rendering with bitwise and, setting the hero to layer 2 and the free camera to layer 1.
Learn to create keyframe animations inside Babylon.js by animating the camera’s alpha, beta, and radius with animation objects, set keys, and loop modes such as cycle, relative, or constant.
Develop a modular multi-level architecture by treating each level as a scene within a game object that holds a scenes array and an active scene index, enabling seamless transitions.
Create a cylindrical portal in the first level to transfer the tank to the second level, using an action manager to switch scenes and vary ground colors by active scene.
Deploy a single-player web game to Heroku by turning it into a web application, initializing a git repo, and pushing to a Heroku app while aligning assets and casing.
Explore building a client-server online game using Babylon.js, introducing the multiplayer section and transitioning the server backend to Node.
Discover how Node.js embeds the V8 JavaScript engine in a C++ program. It translates JavaScript into machine code, enabling it to run on servers and in browsers.
Install the latest stable node.js and complete the setup, then verify by typing node -v in the command prompt, with npm installed by default to support immediate development workflows.
Run your first javascript file with node to print a message. Learn the node module system by exporting via module.exports and requiring modules to share code.
Create a node http server by requiring the http module, listen on port 3000, handle requests with request and response objects, and note Express as a popular routing option.
Initialize a node project with npm init, install Express using npm install --save, and build a minimal Express server that handles get requests for pages and returns simple messages.
Run the game on a node server by copying the single-player files into a multiplayer project and serving with express static, then enable automatic restarts with Nordman.
Learn how websockets establish a persistent client-server connection for real-time multiplayer gameplay, enabling instant updates of players' positions and orientation, new joins, and removals across all clients.
Install the socket.io library on both server and client sides, configure transports to use web sockets, and establish a connection to emit a get your ID event for multiplayer gameplay.
When a new client connects, the server announces your arrival. It broadcasts existing tanks' positions and rotations, colors your tank blue and enemies red, and stores states by id.
Update tank state on movement and notify the server only when position or rotation changes, then broadcast the new state to all clients for cross‑client tank synchronization.
Learn how a multiplayer game uses socket signals on window unload to inform the server, remove the player's tank from active lists, and propagate removals to all clients.
deploy your multiplayer game to Heroku by updating package.json with engines and a start script, set the port from the environment or 3000, and push to Heroku.
Welcome to The Extensive Webgl Series - Part II - Single And Multiplayer Online Client-Server 3D Game Development Using WebGL's BabylonJs.
This is the second course in my extensive webgl series. While watching the first course first is recommended, it is not a strict prerequisite for this second course.
In This course you will learn how to create 3D Games inside BabylonJS. BabylonJs is a very nice 3d game engine written in Javascript, that allows creating very nice games quickly and effectively to be run directly on the browser.
The course is divided into two main sections : The Single-player section, and the Multi-player section.
In The single-player section you will learn the following :
In the multiplayer section you will learn the following :