How To Fix Unity3d Transparent Shader Not Respecting Z-Index

Before and After: Unity3d Transparent Shaders Respecting Z-Index
Before and after. Bright colours used to demonstrate effect of fix.

The fact that, by default, the transparent shaders in Unity3d do not work well behind or in front of objects has been a problem for years. Here’s an easy fix that might solve it for you.

Steps

  1. Make a duplicate of the transparent shader in question. For me, this was Unlit – Transparent Tint. I found it by searching my Project window in the Unity3d editor for “Unlit”.
  2. Edit the new shader in a text editor (default: MonoDevelop).
  3. On line 1, change the name of your shader to something you’ll remember. This is where it will be in your shader selection dropdown in the editor.
  4. Under the SubShader section, add +1 to the item in the “Queue” section. For me, this became “Queue” = “Transparent+1”.
  5. Save your shader.
  6. Apply it to your game object.

That’s it! With any luck, the object with your transparent shader should now appear in front of other game objects which also use a transparent shader.

Using Unity3d 4.x In a Team

I’m working in a team for the 2015 NASA Space Apps Challenge and this year, like last year, we’ve run into a billion and a half problems working with Unity3d and git with more than one person. After some searching I found an awesome website that included a gitignore file that seems to do the trick. I’m not trying to rip them off, but I’m incuding the gitignore file here for my own future sanity (and just in case their site goes down).

# =============== #
# Unity generated #
# =============== #
Temp/
Library/
# ===================================== #
# Visual Studio / MonoDevelop generated #
# ===================================== #
ExportedObj/
obj/
*.svd
*.userprefs
/*.csproj
*.pidb
*.suo
/*.sln
*.user
*.unityproj
*.booproj
# ============ #
# OS generated #
# ============ #
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

Disable Oculus Rift Health Warning (Windows)

Oculus Rift Health Warning

I understand the need for a warning when loading an app for the first time off of the Oculus Share store, etc. but as a developer it’s insanely annoying to have to go through this thing every single time you run your game. So, if you’re working on an Oculus Rift app and you want to get rid of it while you work on it, here’s how to do it in Windows.

1. Create a text file called “oculus3d.reg” with these contents and run it.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Oculus VR, LLC\LibOVR]
"HSWToggleEnabled"="1"

2. Open the Oculus VR Config Tool and click on the “Advanced” button underneath the player height field.

3. Check the box confirming you don’t want to see the warning any more.

4. Develop your game faster by being able to save 10 seconds every time you test your game.

Don’t always listen to advice

When showing someone your start-up/product/service, it’s easy to let them guide your thinking unconsciously. It feels like there’s an inverse proportion of weight given to feedback to sample size, especially if it’s the first time taking the cover off.

Here’s a really great example of why one should always take every bit of advice as advice and not gospel:

advice

 

 

 

Game projects up on github

I’m taking a few hours tonight to go through the archives and put up some of my finished/unreleased/unfinished game jam projects onto github. Ludum Dare 26 is next weekend and I want to have a simple URL to send people to to try out my stuff.

https://github.com/rocky1138/FocusOnFun

Atari Jaguar Dev Journal 002

I took a bit of time recently to take apart two of my Atari Jaguar joypads. The rubber/plastic screwhole covers, over time, had disintegrated and melted into a gooey, sticky mess on the backs and front of the joypads. It was gross.

If you’ve got old videogame equipment (10+ years) and you’ve noticed the rubber/plastic screwhole covers on the backs of the units or controllers getting soft, I recommend taking them off and avoiding the cleanup you’ll be facing in the next couple years. Otherwise, you’ll have to do what I did and use Goo Gone. The good news is that Goo Gone is amazing and it’s fairly cheap.

Melted screwhole cover gunk
One of the screwhole covers.
Joypad gunked up
Joypad gunked up. Note the cat hair that got picked up along the way. Gross!
Type 1 and Type 2, respectively.
Type 1 and Type 2, respectively.
Type 2 (left) and Type 1 (right)
Type 2 (left) and Type 1 (right)

My Oculus Rift Arrives (Hopefully) April 11

So excited for this.

I’ve been planning out my first game. I’m going to call it Barf. Simply, it will change your view in whacky, unexpected ways whenever you move the headset (and sometimes even if you don’t). Online leaderboards (probably powered by Google App Engine or something of the like [is that thing free still?]) keep track of who has gone the longest before ralphing.

Download old 3.5 version of Unity3D

Unity 4 was released three days ago, on the 12th of November. I installed it as soon as I saw that it was available. Unfortunately, it overwrites any previous version of Unity you have installed, so I lost my install of Unity 3. To make matters worse, I could not find any download link on the Unity3d website.

Thankfully, the official @unity3d twitter account pointed me toward the installer for Unity3D 3.5. Here it is.

For PC: http://download.unity3d.com/download_unity/UnitySetup_update-3.5.6.exe
For Mac: http://download.unity3d.com/download_unity/unity-3.5.6.dmg

Enjoy.

Gonna Be Pretty Quiet Around Here…

Will Pwn 4 Food Logo

I’m not abandoning this blog, not by a long-shot. Still, my current work eats up my life these days.

If you wanna follow what we’re doing at Will Pwn 4 Food (and you know you do, because you like videogames just like I do), then come our first game, DodgeBots, and subscribe to our blog.

Android + UNITY + Ouya + Eclipse

My go-to IDE for everything for the past 5 years has been Netbeans, so to switch to Eclipse is something new for me. But, Eclipse is insanely popular, so there’s got to be a good reason for it.

Google seems to love it, too, and it’s always great to be in tune with them. I used to develop stuff for the Google App Engine and it was the same thing as it is with Android this go-around: if you didn’t use Eclipse, it was a bugger to get going. Relying on a third-party plugin from Kenai to access a closed system was just too much of a reach-around and I got out of there.

So, Eclipse. Excited.

Why Android? Well, this recent hullabaloo about Ouya has got me excited. I’ve been toying with game development now for years and after completing a few games in the past few Ludum Dare/7dfps/Guelph Game Jams, I can safely say that the idea of getting my games up on the TV screen with a controller turns my crank.

It was the same thing the first time I played BastardBlaster (my html5/javascript shmup) on the Wii, using the Wii browser and Wiimote. I loved it and wanted to have more.

Playing games on a PC/laptop is just not the same as on a console. Don’t get me wrong, I’ve got hundreds of PC games and love them dearly. But, there’s something special about a controller in your hands and a big TV screen in front.

I’m looking now through the Youtubes and Googles for Android development stories, tips, tricks, hints, tutorials, cautions, etc. If you’ve got experience in this area and would like to share your story, I’d love to read it.

On Game Development and Akihabara

Syrup Dispensers From Hell Screenshot

Syrup Dispensers From Hell is coming along quite well. I’ve decided to use the Legend of Sadness base for the game, which plays and looks a lot like a Legend of Zelda title. Instead of having our hero travel into a cave, he’ll be travelling into a breakfast restaurant to save us all from horrid syrup dispensers.

This time around I’ve got a lot more experience working with Akihabara so I’ve been able to work harder on gameplay and graphics rather than learning how the game engine works. Designing tilemaps for a game, as a programmer, is tough work. It’s not that I dislike working on art or even that I’m not artistic, but what looks great in The Gimp looks like shit when it’s tiled a hundred times.

Doing graphics for a game is basically incrementalism combined with healthy doses of iteration. You tweak a pixel, test it in-game, hate it, go back, tweak another pixel, hate it, go back, and so on.

A neat feature that I discovered today was Akihabara’s ability to scale the size of the game display by a value that is less than 1, meaning that it does not need to zoom to an integer value. Currently I’ve got the game displaying at 320×240 with a zoom of 2.5, making that actual output 800×600.

Well, back to work :)

Audio Conversion Love

I’m under a tight deadline for BastardBlaster, the game I’m building right now for the Guelph Game Jam, so I’ll share my quick and dirty way to convert audio files in Linux and using some Windows software with Wine.

The source music is music modules in the .it (Impulse Tracker) format. So, I used Winamp (running via Wine) to export as .wav files. From there, I used the MP3 to OGG conversion script on this page (modified a bit) to do:

./wav2ogg filename.wav filename.ogg

wav2ogg’s contents look like this:

[rocky1138@atlas Music]$ cat wav2ogg.sh 
oggenc -o "$2" "$1"

Hope this helps someone in the future :) Note you have to have oggenc (vorbis-tools) installed in order for that to work :)

Now to do mp3s….

Grass-roots open-source gaming console?

Earlier today, I had a thought: What if a few of us got together to develop specs for a PC-based open-source games console that uses a bootable Linux-based game DVD for games?

I blogged about the awesome boot’n’play Linux CD before, but it still relies on someone to burn the disc and reboot their machine. Also, this requires gamers to (unless they have a unique set-up) sit at their desk and look at their computer monitor to play games. Finally, you always hope that the bootable disc supports your graphics or sound hardware.

Why can’t we put together some specs for a cheap gaming PC in a mini-atx case, include a TV-out card that has composite, S-Video, and Component output, and offer downloadable ISO game-packs from a website. The system can have a hard disk or can save the games to a USB memory card.

The goal is to make the gaming system as easy to use as, say, a GameCube.

Download the ISO, burn the disc, put it in the console and play.

We’re already half there — the games console could easily use the boot’n’play Linux CD I spoke about earlier. It kind of makes you wonder why this hasn’t been done already?

What Makes a Videogame Fun?

There are several important things that I feel are absolutely required when creating a fun videogame. Fun means so many things to so many people, but for the purpose of this article fun will be defined as a high level of enjoyment obtained by the player as a result of playing the game.

A lot of people look for things like graphics when playing a game. Some people could care less. For some it’s the music, for others, the story. I believe there are several factors that contribute to the fun level of a game and that the fun level is controlled both by how important those factors are to the player and how much of that factor is available in the game itself.

Let’s walk through the eight factors I believe contribute to a fun game. These factors are just that — factors. Think of them as a health bar. Depending on the game, the bar may be full for certain factors or completely empty for others. Rest assured, however, that having a full bar in each of these eight points will increase the liklihood your game will be fun.

The eight “fun” factors:

  1. Graphical Relativity
  2. Ease of controls
  3. Music
  4. Multiplayer capability
  5. Story & characters
  6. Replayability
  7. Nostalgia
  8. Innovation & Novelty

Let’s walk through each of them in detail.

#1. Graphical Relativity

You may notice that on this list I have omitted “graphical quality” and instead written Graphical Relativity. This is because over time I have noticed that the games that are the most fun to the most people are the ones that have graphics that match the game’s premise perfectly rather than overall graphic quality. This is blasphemy to the people with the latest and greatest PC or console hardware, but I believe it to be the truth.

As examples, I cite World of Warcraft, Team Fortress 2, and Tetris. All three of these games have graphics that are not state of the art but all are insanely fun. And popular. They all have staying power as well. For each of these games, the graphics are not the selling point nor are they a point of contention in the gaming industry at large. In these cases, the graphics fit. And that’s the point. It’s not the latest and greatest graphics that matter, it’s if the graphics fit the game.

Try to think of other games that are fun that fit this as well. Games like Crazy Taxi or Street Fighter 2. Can you think of any games where this isn’t the case? If so, are you sure that it was the graphical quality that made the game fun?

#2. Ease of Controls

The Sims was more fun than The Sims 2. On paper, The Sims 2 was a better and deeper game. Why is it that I could stay up all night playing The Sims but couldn’t spend more than an hour playing The Sims 2? Simple — the controls.

The controls for The Sims were intuitive and worked flawlessly. The controls for The Sims 2 were horrendous. That’s not the fault of the game itself, though, or its designers. The reason The Sims 2’s controls were poor was the move to 3D is in itself very difficult for game developers. How does one control a 3D camera without an extensive control scheme? Without some new form of hardware, doing this intuitively with a mouse may be impossible.

#3. Music

This factor is not one that many people think of when describing a videogame. Sure there are examples you’re probably thinking of right now. Zelda, Mario, Final Fantasy… But, isn’t that the point? Why are all of the best and most fun games the ones with the best music?

Something to chew on.

#4. Multiplayer Capability

The ability to play against other players (when done correctly) will (depending on gametype) immediately increase the fun level of your game. Some games even require it. Consider the following example: Super Mario Kart for the SNES. Super Mario Kart without the ability to play against friends would be a completely different (and ultimtely boring) game.

Most gametypes benefit from multiplayer capability, but for others it is almost better to be without it. For example, Morrowind as a multiplayer game would not be Morrowind. For better or for worse, the Morrowind we know and love would not exist in multiplayer. Considering that it’s my favorite game, that would suck and I wouldn’t change a thing. I would be open to a completely separate multiplayer Elder Scrolls game, however.)

#5. Story & Characters

The story and characters used in the game, no matter the gametype, lend to its fun value. As in multiplayer capability, some games require deeper characters than others. But, who says a football game can’t have character development?

Put simply: The more relevant your characters are to your gametype, the more likely your game is to be fun.

For example: Duke Nukem. As a platformer (and later as a 3D game), Duke Nukem is what made the Duke Nukem game series. A Duke Nukem game without Duke is Crystal Caves. Exactly.

#6. Replayability

I believe the desire to replay a game comes from two factors: The desire to enjoy important emotional impacts the game had the first time around and the opportunity for having the gameplay change from the first time you played.

To exemplify the first desire, Final Fantasy VII comes to mind. The game is inherently linear in design. You start in Midgar and end in.. well. I don’t want to spoil it. But, players will replay this game years later to enjoy the deep emotional impact they had while traversing the story the first time, not because they may be able to change the plot.

As for the second desire: This is common in competition-based games. I again call upon Team Fortress 2. Even if you played 1,000 games of pl_goldrush, it’s unlikely that you will have the same things happen twice. This sort of unpredictability is key to increasing the game’s replayability factor.

#7. Nostalgia

This factor is similar to replayability in that you are replaying a game because it brings back memories of what it was like the first time (or another memorable time when you were playing). There are two ways you can take advantage of nostalgia when developing a game.

If your game is new: Pay homage to similar games that inspired you to create your game. If you are making an adventure game, put some references to Quest for Glory or King’s Quest in there. People will associate your game with games they have enjoyed in the past and by reference will enjoy your game because of it.

If your game is a sequel: Take the best parts of the original game and make them shine. Don’t “improve” them as that invariably changes them. By changing the things that made your original game great, you run the risk of alienating people who are playing your sequel because they loved those things. What you want to do is accentuate those selling points.

Compare stealing equipment and items in Morrowind to Oblivion. Oblivion undoubtedly has a deeper and more realistic stealing mechanism when dealing with items and people in the game. However, there are several key things that were changed that makes stealing a waste of time, thereby ruining something that made Morrowind great. Namely, the fact that you cannot place items somewhere and return to them later unless you buy a specific house and the fact that no one has anything good to steal unless you’re at the highest character level, by which point you are done the game.

#8. Innovation & Novelty

Innovation is grouped with novelty since in the gaming world they are the same thing. When Nintendo goes to make the Wii 2, how many people will be excited that they use a remote control with a motion sensor?

However, the first time around this sort of thing can open doors and bring fresh people in. Being able to play games like Doom and Duke3D over local networks in schools and at home was a novelty (though it had of course been done before, it really was the first time I had experienced it myself). Think of when Pong was first introduced. They single-handedly created the arcade industry.

So, what have we learned?

Clearly having a healthy balance of all of these fun factors helps to make a videogame fun. It’s important to not rely on having a large amount in one of the items then neglecting the rest, as that game will be remembered as not being fun but having feature X. The goal is to focus on fun. Fun sells. Fun builds franchises. Fun builds memories.

Thoughts?