This has been a dif­fi­cult week, a week I took off work to A) recov­er from the game jam and B) make an attempt at plough­ing through and get­ting loads of work done on Shh,Zombies (B being the main rea­son). Unfor­tu­nate­ly, I did­n’t make as much progress as I’d hoped, but progress has been made!

Things are going well …

I start­ed the week of by doing small bits, for exam­ple, fin­ish­ing imple­ment­ing the UI and fix­ing some bugs that arose from the func­tion­al­i­ty of it, and tweaked some of the lev­el lay­outs. I realised this was just pol­ish­ing, that could be left until much lat­er, so I changed my ‘To Do’ list. The list still has a few “pol­ish­ing” bits on, but bits I believed would be quick to do and want­ed to get out of the way.

So far so good, now time to start on new lev­els, actu­al con­tent for Shh,Zombies! This was some­thing I thought would be fair­ly quick to do, and build­ing them is — bal­anc­ing them so the Day/ Night solu­tions are dif­fer­ent, chal­leng­ing and enjoy­able is where most of the time is going. Tues­day night, time to do a build and show off the new content!

Uh-oh, what the f- is going on here …

The zom­bie head col­lec­tables are bro­ken! The play­er now just hits them like they’re a wall, but I haven’t changed any­thing?! What’s going on! It works fine in the edi­tor, but not in the build? I spent prob­a­bly two hours try­ing to work out what was going on, I googled: , I post­ed on the Uni­ty forum: , I tweeted:

From both of my accounts:

I was con­vinced my code was fine -
It worked per­fect­ly in pre­vi­ous builds.
It worked per­fect­ly in the edi­tor with the cur­rent build.
It, now, did not work at all if I built it to the web­play­er or an exe.

Any help at this point, was fruit­less, and just con­cen­trat­ed on my code — it was­n’t a code prob­lem, stop look­ing at my code and try­ing to “fix” that! At this point I did­n’t have a clue where to being look­ing, so could­n’t fix it with­out blind­ly pok­ing around — at things I knew would­n’t make a dif­fer­ence — a frus­trat­ing sit­u­a­tion to be in, although I did appre­ci­ate the help. The bat­ter­ies in my key­board ran out, I gave up, went to bed.

Instead of wast­ing any more time on this, I just con­tin­ued with cre­at­ing move lev­els. Whilst dis­cussing my progress with a friend, Mr. Wes­son, on Skype I came up with a new idea, pot­holes! So I rushed off to make the first lev­el (the tuto­r­i­al lev­el) with a pot­hole — issue num­ber 2 arose! The zom­bies, ignored the Y‑axis and just float­ed across the potholes.

This hap­pened because I was using the code below to move and rotate the enemies.

  1. trans­form.posi­tion = Vector3.Move­To­wards(this­Po­si­tion, play­er­Po­si­tion, step);
  2. trans­form.rota­tion = Quater­nion.Rotate­To­wards(trans­form.rota­tion, toRo­ta­tion, maxRo­ta­tion­Speed);

I knew what I had to do here though, had to change to using the rigid­body to move and rotate instead, so now I’m using this code (with oth­er bits of code changed). To my sur­prise, after much fid­dling, this worked AND improved the move­ment, no bounc­ing around now!

  1. rigid­body.veloc­i­ty = trans­form.for­ward * step;
  2. rigid­body.rota­tion = Quater­nion.Rotate­To­wards(trans­form.rota­tion, toRo­ta­tion, maxRo­ta­tion­Speed);

This brought back an old issue, that I had for­got­ten about (it only hap­pens when my set­up is rigid­body + ani­ma­tion), the col­lid­er does­n’t stay with the ene­my mesh prop­er­ly. This issue is still a work in progress to fix, for now I just have the ani­ma­tor disabled.

Eureka !

Thurs­day was a long, hard day, which came togeth­er by the end. I had the ene­mies mov­ing prop­er­ly and falling down pot­holes, I had a tem­po­rary solu­tion to the col­lid­er not stick­ing with the ene­my mesh and by the end of the day I had fixed the col­li­sion issue on the zom­bie heads!

I must thank a user on the Uni­ty Answers web­site for help­ing me,‑f.html , I’d almost giv­en up hope, but he lead me to sal­va­tion! The place where I could work out what was going on. The prob­lem was that the mate­ri­als for the det­o­na­tor explo­sion had lost the con­nec­tion to the det­o­na­tor. The Uni­ty edi­tor added them auto­mat­i­cal­ly when instan­ti­at­ing the object, where­as the build would­n’t. Re-adding these to the pre­fab fixed the problem.

Doing a devel­op­ment build, which I had­n’t thought to do and did­n’t know what it did until now, gave me the answer. It was clear from the log what was hap­pen­ing. Such a relief!

Some­thing else good came from this, I realised and changed my code for the zom­bie head. Hope­ful­ly now it’s more opti­mised(?), prob­a­bly does­n’t give a big gain in any­thing though. The code changed from this:

  1.     void OnCol­li­sio­nEn­ter (Col­li­sion col­li­sion)
  2.     {
  3.         if(col­li­sion.trans­form.tag == “Ene­my”)
  4.         {
  5.             Physics.IgnoreC­ol­li­sion (head­Col­lid­er, col­li­sion.col­lid­er, true);
  6.         }
  7.         if(col­li­sion.trans­form.tag == “Play­er”)
  8.         {
  9.             Noti­fi­ca­tion­Cen­ter.Default­Cen­ter.Post­No­ti­fi­ca­tion(this, “Count­Col­lect­ed”);
  10.             explo­sion.Get­Com­po­nent <Det­o­na­tor>().Explode();
  11.             Destroy (this.gameOb­ject);
  12.         }
  13.     }

To this:

  1.     void OnTrig­ger­Enter (Col­lid­er col­li­sion)
  2.     {
  3.         if(col­li­sion.trans­form.tag == “Play­er”)
  4.         {
  5.             Noti­fi­ca­tion­Cen­ter.Default­Cen­ter.Post­No­ti­fi­ca­tion(this, “Count­Col­lect­ed”);
  6.             explo­sion.Get­Com­po­nent <Det­o­na­tor>().Explode();
  7.             Destroy (this.gameOb­ject);
  8.         }
  9.     }

Now back to work mak­ing more levels!