Help with Unity 5.5.2f1 Building

Hi all!

I have made a block breaker and it is soon ready for “launch”, just a few more fixes. So I though I update to the newest version of Unity to make it stable on Chrome on WebGL.

It works a bit on GameBucket (a few wierd bugs like breaking the set 800x600 game screen up to 1024x800 and such, making the pictures miss (and yes, it IS locked to 800x600, I relocked it after updating to newest Unity), some lag, some missing sound files and the like…

However, with a little bug fix I will probably get to that. What I do not understand at all though, is this bug I get when I try to build and run WebGL without uploading to GameBucket:

What this means, and how to solve it, and how that relate to the bugs I experience with the GameBucket builds… I simply have no clue.

Help?

Pleeeeease?

Your truly,
Opticul.

ps: Everything runs just smoothly on editor. No bugs except occational “inconsistent line endings” in Visual Studio, of which google say have no effect what so ever on anything. Either way, I let Visual studio fix it to windows endings. All other bugs (like level change, particle renderers and such) with regard to changing from 4.6 -> 5.x is solved.

How are you trying to run the game? e.g. what are the steps you take?

The localhost:60986 suggests you may be running your game under IIS on your computer, 60986 is the port number IIS is using. Can you confirm whether this is the case.

Also, sometimes you may see this error if there are spaces in your folder names, when running locally, JavaScript isn’t overly happy with those. Can you confirm whether this is the case? For example, a folder named “Block Breaker” perhaps?

I press “Build and run” in unity under WebGL build, default settings for webGL build (except I just adjusted screen size to 800/600). Image of this is included.

No spaces in folder name nor subfolders, only parent folders (Block breaker webGL\BlockBreaker\assets and so on, the entire build is within Blockbreaker. If it might affect it, some of the music files have underscores and a couple of the prefabs and assets have two names, but I assume that should not matter.

Also, I am not really writing in JavaScript, the entire project is in C# as the tutorial indicated.

I have NO idea what IIS is. I did copy some random **** from the internet on an earlier build that was supposed to fix this bug (some default state in an web.config file). This removed the error message but the game did not actually load so I removed the file and asked for help instead.

Hi,

Depending which version of Windows you have running and which components you have, you may have Internet Information Services (IIS) installed. IIS is used for serving web based content. It’s quite possible that the Build and Run is building your application and then trying to run it under IIS - this would explain the localhost and port number as IIS would provide a random port number each time (if configured to do so).

I appreciate you are not typing in JavaScript, but JavaScript is used when it comes to launching your game under WebGL. If you open the /TemplateData folder (created when you build) you will note a few JavaScript files located there.

As a test, why not just try using Build rather than Build and Run, then, browse to the directory where it has built the game. You should see the index.html file, double-click that and see if you get a different result, specifically, a differing URL in the browser, and ideally, the game running.

Let me know how you get on.

Edit: I forgot to say: Thank you for help!

If it did, it was not intended to be running any IIS stuff.

I realise much stuff goes on in the backoffice in Unity. I write stuff in C#, which is compiled in some unity language which is translated to c++ which again is translated to javascript. I think I should be happy it does it for me at this point ^o^

Build worked better, and I removed ALL spaces from everything, even sub and parent folders. No idea if “build and run” would work now, but at least build does work. I also got rid of the size error on the screen, so now it works locally (works well, but does not work on Chrome) and on gamebucket (with some lag and almost 5 minutes load time to start the game), also working on Chrome.

Any advice as to how to avoid lag and/or what drives lag and long load time? There is quite a lot of different things that going on in my block breaker so hard to pinpoit. All sound effects are at 70% quality, overridden for webGL and “compressed in memory” as some webpage reccommended for medium sized files being played often. I have many images (backgrounds and such) but they only account for 6 mb of space so it should not take forever to load.

I can link you the game if that helps, but for anyone NOT doing troubleshoot, please don’t try the game yet :smiley: I will publish on all forums when it is complete ^o^

http://www.gamebucket.io/game/7db04588-8211-4c31-82f5-0ca01e1f637b

(Just a quick question even though I am pretty sure the answer is no: Is it possible to disable the full screen button on gamebucket in script? The game is not and will not support full screen)

1 Like

The ball is the object that lags most, it has the following code attached to it in fixedUpdate to regulate speed and it has a continous collision detector which I have heard increases cpu demands, but I sort of hoped it wouldn’t increase it enough to break the game.

void FixedUpdate() {
	if(hasStarted) {if (this.GetComponent<Rigidbody2D>().velocity.magnitude < gameMachine.ballSpeed) {this.GetComponent<Rigidbody2D>().velocity = this.GetComponent<Rigidbody2D>().velocity*1.05f;}}
		if(hasStarted) {if (this.GetComponent<Rigidbody2D>().velocity.magnitude > gameMachine.ballSpeed) {this.GetComponent<Rigidbody2D>().velocity = this.GetComponent<Rigidbody2D>().velocity*0.95f;}}
	    	    	}

This is added to the ball in start function, because the game supports “higher and lower ball speed” drops which broke the walls without it.

GetComponent<Rigidbody2D>().collisionDetectionMode = CollisionDetectionMode2D.Continuous;

The game has no gravity, so there should be little conflict in the physics engine in that regard.

1 Like

Edit: I forgot to say: Thank you for help!

You are more than welcome :slight_smile:

If it did, it was not intended to be running any IIS stuff.

Might be worth looking at your installed Windows components and just see if it is installed, if it isn’t something you are familiar with, or need, you could remove it, or just use “Build”.

Any advice as to how to avoid lag and/or what drives lag and long load time? There is quite a lot of different things that going on in my block breaker so hard to pinpoit. All sound effects are at 70% quality, overridden for webGL and “compressed in memory” as some webpage reccommended for medium sized files being played often. I have many images (backgrounds and such) but they only account for 6 mb of space so it should not take forever to load.

That’s a fairly broad question, as there are a number of factors to consider in your specific case. Firstly, I don’t know what the server specifications are for the GameBucket.io server, this could be a factor if the server was getting a lot of traffic/requests (I doubt it is). Internet connections… I think I’m on a 100mb line here and get typically around 60mb… your game took about 3-4 minutes to load for me… initially I was counting, after 110 I stopped counting :slight_smile:

Most likely the size of your assets is a significant factor but also the actual design of the game itself, and this gets covered in Glitch Garden… but as an example, and this isn’t a criticism of you or your game, just an example;

I clicked on your link and after a few seconds was presented with the grey square as the GameBucket.io site responded to me request. I am familiar enough with the student games on this site to know that this is fairly normal, so I patiently waited. As I mentioned above, I started counting the seconds just to see what the lag was like. After 30 seconds I was bored of counting the seconds, but was trying to help so continued, at 100 seconds I was REALLY bored of counting the seconds, at 110 I stopped counting the seconds and flicked to another tab whilst it carried on doing it’s thing in the background.

This is actually quite a big problem, if you share your game with people (fully appreciating you are working on it etc, this is again just as an example) they will have certain expectations, as you can see from my text above, after 30 seconds I was bored of waiting. There was nothing on the screen to indicate that anything was actually happening. “Should I go back and click the link again?”, “Maybe I should refresh the page?”, these are thoughts your players may have and in this case, by doing so, would only make them have to wait even longer.

So, how can we resolve this? Assuming at this time that we are unable to determine whether the server is slow, or whether there are any networking issues, or whether we could improve the size of your assets, the one thing we could change is your game architecture.

At the moment, the player has to wait for the firs scene to load - it’s loading a lot of assets back there, just for a screen with some buttons to press and some music… again, this is covered in Glitch Garden, but you could add another scene to the build order, perhaps a very simple background image, a title, and a little piece of music - nothing big, but considerably smaller to load than the main menu. You would need to add a check for when things are ready, but then flip to the main menu once the loading is done.

This way, whilst we haven’t really changed anything in the background, the player is at least greeted by your game, they know at that stage that it is working, they get a screenshot that sets some expectation of what they are going to be able to do - so make it cool or mysterious, so that they will be keen enough to hang on for those extra seconds to see it, your music will be a nice distraction (as long as that loads quickly!)… then fade out perhaps gracefully to the main menu.

At this stage you should be able to achieve this reasonably easy, you can obviously create a new scene, you can add the title, the music, maybe you need to find a code example or ask for help for the loading the main menu when ready, or the fade, but having seen what you have already added to your game I don’t suspect this would be a big challenge. Equally, you could skip ahead a few lectures to just see the bit about the loading screen and then come back :slight_smile:

After this, if it were me, I would probably be looking at asset sizes next, and whether the code is efficient.

Is it possible to disable the full screen button on gamebucket in script? The game is not and will not support full screen)

My understanding of the GameBucket.io website is that it simply returns your index.html page in an iFrame. As such, if you have a look in the /TemplateData directory that you have after building and looking at the index.html file, you may be able to make some changes to it there

The ball is the object that lags most,

I can’t say that I really noticed that when I was playing, it did a little at the beginning, but seemed okish after that…

it has the following code attached to it in fixedUpdate to regulate speed

Ironically, this probably isn’t helping. FixedUpdate() is necessary when you are using forces and physics. You can use Update() and then to allow for the time difference between frames and Update calls, use Time.deltaTime

it has a continous collision detector which I have heard increases cpu demands, but I sort of hoped it wouldn’t increase it enough to break the game.

It will increase demands, but lets be realistic, this is one ball moving and the paddle moving around the screen, this isn’t going to be a problem. In fact, not having continuous set would introduce potential other issues, such as the ball not registering collisions with blocks, or worse, the paddle!

I hope the above helps, and those links are also listed below for convenience.

You have a nice game coming along here, well done, you’ve implemented a lot of cool ideas, keep it up.

p.s. typo on the menu screen “Achievements” :slight_smile:


Thank you for help, feedback and support!
Glad you like what I have being doing with the game :slight_smile:

Heading to England for a trip, when I come back I will:

0: Fix the typo (plenty of other small annoying changes I will fix, like auto-focus on input box in start of Profile scene)
1: Try to reduce asset size (got 63mb of sound effects and a total of 72mb assets)
2: If that does not solve it, run ahead and look at the glitch garden content on this and if that does not solve it
3: Make a load screen and/or load music assets in another window after the game has started.
4: Look into code efficiency (any links to that? I would not really know where to begin. All I have been practising is: As little as possible in Update(), shortest sensible data flow (usually just from object to storage singleton and from storage to menu.))

There were all sorts of bugs before I made collision continuous, that is the reason I bothered to upgrade from 4.6 at all. Did not find a good legacy way to implement continous collision.

The fixedUpdate application of force works perfect to adjust speed of the ball, even when I change ballspeed int ingame, it regulate the constant speed of the ball to ballspeed regardless what happens to the ball. I have on purpose avoided touching Time, pop up menues and coroutines because I want to learn that from the tutorial. If it is one of the causes of lag, I will of course change it, if not I rather not change what is not broken :slight_smile:

Great that the ball does not lag in your end! Maby it was just my computer being stressed after tons of uploaded versions :smiley: