Showing posts with label space shooter. Show all posts
Showing posts with label space shooter. Show all posts

Tuesday, February 23, 2016

Unity Bug #2 - That was Fast (and funny)

Thought I'd be smart and fix the increasing difficulty Vector3 issue by just making the velocity of the asteroids faster and faster based on the wave count.  So I exposed the wave count on the Game Controller and accessed it via the move script where asteroids keep set their velocity based on a public property.

I forgot to account for my wave array being 0 based.  I failed to account for the fact that my shots and asteroids were tied to the same velocity/move script, meaning my bolts go faster as the asteroids go faster.  Perhaps not a bad thing, although strange.  And my ship's movement isn't tied to the same movement script, so it doesn't get faster as the rocks start to shoot down the screen at breakneck speed.


My first bug

I've got music and waves going and scoring and restart in my Unity3d game.  And then I tried to get fancy and add a value that slowly moved the waves closer and closer.  I thought I should add:

1.) waves move closer and closer or faster and faster.
2.) objects that aren't shot, but pass the player and destroyed against the boundary are negative points.
3.) each shot is potentially a negative point (because I'm a dick)
4.) a shot counter and objects destroyed to track a few stats to show at the end
5.) a ship destruction value (because I'm a dick)
6.) potentially a few lives with the ability to get more with a higher score.  I hope that rolls over and gives infinite lives because it would be old school.

So I started on #1 and moved the asteroids 5 units closer after the first wave.  Result...unshootable asteroids that, after the first wave, became ghost asteroids.  It seemed to be a float value and I was adding an int, so I modified it and tried again.  Same behavior.  So I use the range for the y value like the x value and added the number directly as an int and then a float.  Same behavior.  It's exciting to have a coding challenge, even if it's minor.

I feel like I'm coding VB COM again.  A lot of setting .Text against text objects and just sort of attaching things to each other to use them.  It would be nice if some of the students I interviewed played around with the Unity tutorials just long enough to talk through the object structure and why you have to locate the game controller rather than instantiate try to access it from every instance of a tumbling rock.  Good lessons there.