Showing posts with label unity3d. Show all posts
Showing posts with label unity3d. Show all posts

Sunday, March 20, 2016

Unity on iPhone

I have to say, the Unity app for the iPhone seems to be lacking without bluetooth, but the fact that I can just wire it in and run my app simultaneously on a PC desktop and iPhone is amazing.  Seriously cool.  Having to download 22 GB of install because I didn't grab the iPhone/Android/et al packages the first time?  Not so cool.  But that was my own fault.  It's slick to point the app at multiple platforms with so little effort.


Friday, March 11, 2016

Troubleshooting

The presenter in the Scavengers tutorial barrels along faster than I can type, and I'm not slow.  I was pretty sure I'd miss something.  And I did.  My food and soda wouldn't pick up and it took me a long time to realize I'd misnamed my method with 2d instead of a 2D.

But what really got me wasn't something I could control.  When my level was resetting, it wouldn't recreate the board.  I changed from a deprecated method to the new loadscene version.  And then I started putting in debug.log statements (didn't I say this felt like old school VB once before?).  After trying to narrow it down, it appeared my Awake function wasn't triggering, so the board wasn't repopulating.  I compared their completed version with my version of the script, and the prefab, everything else, all to no avail.  Finally, in this five year old post (long before the current version of Unity) someone mentioned that Awake() doesn't always refire and you have to code it up under OnLevelWasLoaded() to catch logic after the first time.  I dropped it in there - cut and paste rather than appropriate refactoring - and success!  So for anyone else who's getting Awake() or InitGame() events that aren't firing when they expect them to, OnLevelWasLoaded() is a good place to call your logic again to be sure it triggers.

You can see the affect of the bug on not rebuilding subsequent levels in the video.

Monday, March 07, 2016

Disturbing

I messed up the animation script for the roguelike tutorial in Unity.  It's a little worrisome looking.  I said at one point he was just standing around wanking.  Seems even shadier in this video.


Saturday, March 05, 2016

Adventure Game, Progress

I took a short break during some coding to go for a bike ride.  Darn nice out there, although still a bit chilly on the gloved hands if you're moving fast.

I ran into a few issues getting the basic board controller working.  I dragged the sprites onto the game objects rather than into the sprite controllers, so when I ran the board creation loops, there was nothing to create.  Had me at a loss because my code looked spot on but I was still seeing a great big empty field.  Took a lot of work to clean it all up because modifying the prefabs resulted in messing up my board controller.



The tutorial walked me through a singleton pattern attaching the game controller to the camera by checking for the singleton instance.  I'm never going to believe a Unity programmer again when they tell me they don't know any software patterns.

There's my Win32 meltdown that crashed Unity.  I'm pretty sure it's because I made an instance of the prefab and then deleted the prefab in an attempt to make a new prefab.  I can't be certain, but I suspect it's like having an instance of an object with no object?  The important thing is not to do it - very messy.


80/20

The 80/20 rule (Pareto Principle) applies to playing around in Unity3d as well.  80% of the work comes from 20% of what you're working on.  I decided to move on beyond the Space Shooter tutorial when I got to the part where I'd need the Apple or Android SDK (or Windows).  Not that I'm adverse to using them or can't, I've used all three, but I thought learning more basics rather than significantly more configuration work was preferable.  So I started the 2D adventure game tutorial series.

1.) I was immediately amused because I'd had an intern candidate telling me about his Game Conference challenges using Unity2d and he'd discussed a "cookbook" game with a demon hooking to a JSON data source.  The Scavengers setup sure seems like the base application his team likely modified for their competition.  Wish I had played around with it before the interview.  I don't think he was expecting an interviewer who'd touched Unity (recently).  I asked a number of questions related to prefabs and how they compared to a traditional OOP structure and whether coroutines were threading (they're not, and there are a few tutorial videos out there on the topic of yielding to the main thread versus spawning new threads in C#).

2.) Getting back to the Pareto Principle, during the first real lesson after the introduction, I did something that eliminated my main camera.  So when I went to watch my little adventurer bounce up and down like he was wanking to pass the time, I couldn't find him.  Or his two wanking monster buddies.  I had no problems putting the camera back, but the default settings weren't the same.  I eventually had to boot up a new project and check the defaults.  Unity was resetting the Transform.z to 0 instead of -10 and the depth to 0, instead of -1.  I updated the values and there they were.  Like looking for a needle in a haystack.  Here's a default Main Camera, should I ever need to get my mitts on it again.  It took quite a while of dicking around with settings and looking online before I gave up and did the new project.  Seriously - I'm still trying to make it work in my head - I assume because my characters were at 0 and my camera was at 0, that I was in some sort of Flatworld universe where I couldn't see them.


Tuesday, March 01, 2016

Enemies

Reorg day!  The best, right? This one looks like it will be "directionally correct" in that I go from several business units to just one (but one with multiple people) all pointing at similar functionality even though it's in multiple products.  One of my rules has always been that if you can minimize business units, you're better off.  Gives your life a focus you don't get with half a dozen of them competing for your priorities and you ending up feeling like you're not making anyone feel special (or happy).

But on to a bit of code.  Although, as I think I've said before, I'm not sure this counts as anything other than configuration coding as long as I'm generally following video instructions.  But fun.  I got the enemies running with tilt and shooting, so altogether, it actually looks like a real game.

One of the things I noticed is that my bolts weren't deinstantiating even though I'd set it up.  Eventually I realized that it had to do with turning off the GameController which was the object controlling destruction of the bolts after a while.  It's just a checkbox, but it makes a big difference.  It also controls whether the enemy ships can actually destroy your player ship, so it's pretty obvious when you've temporarily disabled it.


Here's the video of the full game in action.  I upgraded to a record with sound so you can appreciate the music and the explosions.

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.

Sunday, February 21, 2016

Unity3d - the Asteroids

I've made it as far as adding the asteroids on a wave basis and allowing for explosions between the shots and the rocks and the rocks and the ship.

I'm also reading Nystrom's Game Programming Patterns, which make sense in the context of the mesh and transforms I'm using, but is much more about traditional software patterns.  Still, a very good read.

Friday, February 19, 2016

Destroy the Object

I'm tempted to use Unity3d as an interview tool for intern/new grad candidates as a great example of the dangers of not getting rid of your objects.  It was cool to see it hang on to shot objects forever because they never ran into a border which would de-instantiate them. Why are interview candidates not infinitely smart compared to me when I was looking for a job?  Seriously - with tools like this, you should be able to talk for hours.  And hours.


Tuesday, February 16, 2016

Ship

I've got my ship flying around in the second Unity tutorial.  I think 20 minutes a night (really about 30+ of work) is about as much as I can manage. I'm going to declare it good progress, despite the fact that I can fly off the bottom of the screen. I fixed that - I just have to remember if I edit values while I'm in play mode, they revert.

That error message isn't for me - that's leftover Unity 4 stuff from their finalized scripts in case I get lazy.

Monday, February 15, 2016

Science ##

I was working on a new Unity tutorial today that involved multiple light sources.  I find it amazing that I can use a piece of software to just create different levels and hues of light and the physics within the application takes care of smoothing it across the object/s.  That's an amazing amount of power to wield with almost no programmatic effort (on my part).

Here's a main light, rim light, and fill light, all bouncing off my main object with varying intensities, hues, and positions.  It mostly came down to copy and paste.

It reminded me of this cover from the Science magazines my parents ordered for me when I was younger.  There was one cover where they showed several pool balls rendered by a computer.  In 1984, this was freaking magic to me.  The fact that it was difficult to even find the covers tells you how early in popular computing 1984 was.  I couldn't find the correct magazine searching on line, but Kyle tracked it down.  It's the one in the upper right corner.  But searching around for the right cover let me see all the issues that I remember.  There isn't a single issue of this magazine I didn't cherish and read and reread and there wasn't a single cover that I didn't immediately remember.  Between those and Gaming magazine, that was a huge part of my teenage reading (well, and Mack Bolin books at $0.10 each from the flea market, but that was altogether different).  That 20 discoveries that changed our lives issue I carried around with me for weeks; maybe even months.

There was one on sharks (I believe that was early on, Science 81) that had me obsessed with the critters.  As well as this one about undersea exploration from the same year that was so cool.


And this one, a larger version of one of those in the montage above, which is a beautiful cover.  There's a wikipedia article on the magazine, but it's short and no associated covers.  Probably worth fixing were I so inclined.  The article includes this sad bit, that I remember well because I hated the format of Discover compared to Science ##, "Science was purchased in 1986 by Time Inc. and folded into Discover, the last issue being July 1986. A few issues of Discover after the merger feature a stamp noting "Now including Science 86", but this quickly disappeared. This claim was somewhat suspect, however, as all of the Science staff was immediately laid off after the takeover."




Sunday, February 14, 2016

Unity 3d - First Attempt

I am exceedingly proud of being able to follow instructions. I have a board game I'd like to make...actually two or three or four or five. And between Unity and Snap SVG, maybe I can create online and paper copies. I'm not sure they'll ever be for anyone but me, but still, fun to see something I can qualify as a product instead of only in my head.