[Game] Village Craft

Thank you! I’m experimenting with WebRTC now. Who knows maybe some days the game will be online multiplayer…

2 Likes

this is amazing, is something i would like to try, can i DM you to ask some questions?

Of course! Feel free to ask me here or dm. Also I updated the first post with Discord link

look, i think a project like yours covers perfectly all that a newbie needs to know, so i will put some questions so you can reply to them when you have time:
1.- are you using Groundmesh for the floor of yout game, if so, how do you separate the grass from the path an so on?
2.- what kind of camera are you using?
3.-models and textures are made by you/your team or you downloaded those resources?
4.- are you using babylon.gui for the HUD?
5.- how big is your scene (i mean dimensions ) cause i know those rocks that sourrounds the scene are to not to show the void, would you recommend a bigger scene?
6.- what kind of ligth are you using there?
7.- what are you using JS or TS, what is your development setup?
8.is that project repository public? if so can you paste the link so i can study that code
9.- what does babylon has that three.js or other libraries you used does not?

for now those are enough

Sorry, was busy a bit.

  1. I use only one mesh for ground + uv
  2. ArcRotateCamera
  3. I use models from Asset Store and customise it via Blender
  4. No, I don’t use Babylon’s GUI because the library costs me +1mb of JS bundle. So basic HTML+CSS works good for me in the current project.
  5. I don’t use culling in any way) I just draw all scene because I have optimised scene graph. So I think it depends on how much DrawCalls and Vertices you have at one time in the camera.
  6. Only Hemispherical light
  7. TypeScript + ViteJS work best for me!
  8. It is commercial project so I can’t share the source.
  9. BabylonJS is a game engine for me while ThreeJS is just a library to render 3d. So you can use a lot of stuff from BabylonJS like Sprites, VAT, Sounds and etc from the box.
2 Likes

Update 12

The last week was really hard for me.

I’ve implemented the streaming content system. It helps me to load only necessary resources for current map. Why? Because now the game has several maps - Home, Village, Mountain and Temple. I want to add another several maps in the next iterations…

So what I have:

  1. Unity Editor + Custom data format to support multiple maps(zones). I export this data as GLTF files + JSON with description where each object should be located.

  2. Custom data format allows me to use ThinInstances under the hood. So it improves the FPS for large amount of objects. Before this I had 1100+ active meshes in scene. Now ~200 with the new 3 maps.

  3. The loading time also has been improved because on startup I only download required resources for Village map. Others resources have been downloaded in the background. I can improve it more by “prefetching” it without initialising in memory. Will this stuff Loading Assets From Memory | Babylon.js Documentation work for network prefetching?

  4. So now when I have maps I can improve CPU computation time for ECS’ systems. I mark my entities with “map” component and process only entities in the current map(it works great for renderSystem because you don’t want to render entities in the others maps, you can’t see it).

The global release is coming! In the meantime, the game has 4 000 000 plays! Thank you guys for your support!

3 Likes

Network prefecthing should work with any call you are doing (using xhr or fetch)

1 Like

So my solution will be as simple as fetch('file_url.glb'), right?

correct :wink:

1 Like

Hooray! The game has been globally released on Poki today! I’m so excited!

It is really cool to see how many players enjoy the game. And I really like BabylonJS! It is a gem!

6 Likes

Update 13

I see that Google Play starts to promote my game a little bit. I have total 130 users. It’s good) But I realised that the game didn’t startup without internet.

So, if you know, the Web already has a cool tool - ServiceWorker!

My sw.js file:

///  Auto generated
const version = "0.18.2";
///  Auto generated END

self.addEventListener('install', event => {
  event.waitUntil(caches.open(version));
});

self.addEventListener('activate', event => {
  event.waitUntil(
    caches
      .keys()
      .then(cacheNames =>
        Promise.all(
          cacheNames.map(cacheName => {
            if (version !== cacheName) return caches.delete(cacheName);
          })
        )
      )
      .then(self.clients.claim())
  );
});

self.addEventListener('fetch', event => {
  const url = event.request.url;
  if (event.request.method !== 'GET' || url.indexOf('/node_modules/') !== -1 || url.endsWith('?import')) return;

  event.respondWith(
    caches.open(version).then(cache => {
      // Go to the network first
      return fetch(event.request)
        .then(fetchedResponse => {
          cache.put(event.request, fetchedResponse.clone());
          return fetchedResponse;
        })
        .catch(() => cache.match(url));
    })
  );
});

And we need to register the service worker somewhere in the code:

  window.addEventListener('load', () => {
    if (!navigator.serviceWorker) {
      return;
    }
    try {
      navigator.serviceWorker.register('/sw.js').catch(error => {
        console.log('ServiceWorker registration failed: ', error);
      });
    } catch (e) {
      console.error(e);
    }
  });

As you can see, I use “Network first, then cache” strategy. So the users will receive any updates if they have a connection.

As a bonus, you can play on PC/mobile while you’re on a plane… (I was surprised how many mobile games didn’t work without connection).

Update 14

Working on a Terrain Editor. I made my own shader to draw the terrain with two textures - splatmap(s) atlas and tiles atlas. So basically there is no any limitation about how many “layers” you can use. For my game I’ll use up to 16 tiles and 4 splat maps.

Another task is updating character’s model and clothes…

2 Likes

Update 15

Some progress: foliage + terrain.

The color palette should be adjusted. But I like a new look!

What do you think, guys?

4 Likes

damn, it’s looking gorgeous @Alexander_Sosnovskiy agreed, the color palette could be adjusted but the overall look is way better :slight_smile:

1 Like

Update 16

Added scale for terrain’s tiles.
The wall was updated.

All terrain’s textures also were updated. Now it closer to what I want)

Also I want to add a new building - Warehouse, where you can sell products(instead of dropping into trash bin)

5 Likes

Update 17

OMG how time is fast… Almost 3 weeks from my last update.

Some finished items from my tasks board:

  • use height map for building a terrain geometry (via GroundMesh).
    – it allows to get a height of a point in X,Z coordinates;
  • add heightmap’s patches: when player build a dock, we need to “patch” the heigh map for getting a higher Y positions in some coordinates;
  • new textures and models for buildings & items, new textures for terrain;
  • new Attributes System base on this article The power of the Attribute System
  • custom collisions system: I need only 2d collisions so I decided to write my own based on this code: GitHub - devcem/playcanvas-physics: Simple physics for casual games Only 2kb) I’ve added a Y rotation for boxes as well.
  • I’ve refactored spawn system so now I can easily add a new type of gathering like mining, herbalism etc.
  • ktx2 has been investigated: the size of images - 30-35% disk space!!! I’ll integrate a post processing for my image resources a little bit later! But it is a huge win not only because of physical size, but VRAM size too!

The most important things in my to do list now:

  • combat system re-working;
  • re-working 3 locations;
  • character’s model and customisation (as well as NPCs);
  • home decoration;
  • more VFXs;
6 Likes

Update 18

Hey!

There are a lot of new things!

  • new female character!

Still working on new locations and combat system!

8 Likes

This is looking sooo nice! :smiley:

1 Like

This is so cool to see the ecosystem you created to grow like this !!!

1 Like