Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Day 2:

Today I've finally done some serious work.


I've made a main menu. Currently it's just for starting a new game, selecting language and quitting the game (not on webGL). The most difficult part of these are of course translations in different languages. They are kept in streaming assets as json files. I'm using Jsonutility class which is rather simple to use, though it has its own disadvantages (For example it doesn't handle nulls. It doesn't crash - it just makes object with default values on fields.) however they are not important here. What is important is the fact that I decided that my game is going to work in webGL. On Windows checking for available translations is easy: just use DirectoryInfo class to search for files that match the pattern *.json, obviously this doesn't work on webGL. Instead I've created additional file index.json with list of available languages. Additionally class WWW which is used to get file from url is getting the file asynchronously. I'm using callback function and have loading screen to wait for file. That sound complicated. Good thing that I've already faced these problems in my other game I'm making, and pretty much copy-pasted code from there.


Next step was to create simple first level using assets I've downloaded yesterday. After some time I've managed to get character to move and jump. I've considered using either adding force to rigidbody 2D or changing velocity. First I tried adding force. While it makes sense for jumping, walking looks really artificial for me. I considered using force for jumping and changing velocity for horizontal movement, but forces are discarded by manual velocity changes. For now I'm changing velocity for both vertical and horizontal movement.

My character was moving and jumping, but there was a problem. They get stuck on the side of the wall while jumping. After searching for solution  I added platform effector 2D to the platform, and made collider to use it. It worked partially, my character was still stuck on upper corner. Fortunately after I changed their collider from capsule to capsule on down end and box on upper end everything seemed to be working smoothly...

...until I exported it to webGL and playtested. For some reason character doesn't want to jump when their are on effector collider. It only happens on webGL. This is probably connected to the way I'm checking whether character is grounded. I know two ways of doing that. First is using raycast with layer mask. I didn't do this. Instead I've made small trigger collider under the feet of character and I'm checking whether it's crossing any collider with layer mask. I've checked browser console and there are no errors or warnings, it just doesn't detect that character is grounded.

This is all I've done today. I've uploaded current state of game to my draft page, and I'm going to bed. Tomorrow I'll see whether I'll fix it or just give up on either detecting grounded state this way or having webGL version of the game.