Monday, November 28, 2011

IOU: One UV Animation Tutorial

Note to self: post an explanation of how to create animated textures on non-particle objects when (I? You?) create an animated texture.

I've discovered that renderer.material.mainTextureOffset works just fine on line renderers. This would be useful knowledge since I intend to use this property to create animated textures.

Now if only I could remember what I was going to use an animated texture for. Grr…

Here's a picture of the player's primary melee weapon, the Modular Blade. It's a work in progress.

Sunday, November 27, 2011

Triple Feature: Charged Shots and Fickle Billboarding

You don't always solve a problem the way you'd thought you would.

Here we have another one of the bullets the player can fire. The projectile, in its finished form, consists of three…well, four, technically, but you can see the trail effect here…elements.
One is the actual bullet.
Two is the glowy aura thing surrounding the bullet.
Three is another glowy thing (you can see this behind the bullet on the right).
What I wanted was…wait a second, I need to explain what billboarding is first.

Billboarding is an effect that makes an object always face the camera, no matter what angle you're looking at it from. It's commonly used for particles and glowing objects. You can see it being used in the image on the right.

What I want for this charged shot is for the glow surrounding the projectile to be billboarded, but only around its z-axis, so it surrounds the shot at all times. The other glowy object will be fully billboarded, and surrounds the projectile when looking at it from the front or the back.

I tried modifying the billboarding script to get the effect I want, but to no avail. However, I did come up with a different solution.

Instead of making the first glow a billboarded plane, I realized I could use the line renderer effect – this creates a plane that follows a line, and rotates around the line so it faces the camera. Exactly what I was looking for.

Here's the final product.

See you next update.

Triple Feature: Particle Texture Fade

Here's a solution to something that annoyed me for weeks.

One of the player's weapons fires what can best be described as lightning rings. They can bounce off walls. When they explode, they expand and fade away.

Or…they're supposed to fade away. In practice, this happens:
The rings expand, but they don't become more transparent, and they don't disappear. For some reason, the unity scripting language can't find the color attribute of the explosion material.

Yeah…some reason. In the unity programming language, you reference most material's colors with this:
Or, more simply…

But that doesn't work with materials that use particle shaders.

After extensive investigation, some experimentation, and a failed attempt to use a script I got off the 'net, I concluded that particle shaders don't have the color attribute. So, the question is, what do they have?

I managed to find a script for a particle shader, and found that they have this:


Bam, problem solved.

Triple Feature: Progress Report

Well…it's been a while. I've made some progress since I last posted.

I've written AI scripts for enemy behavior. The Seraph I showed you now has two different attacks – a claw slash and a laser projectile shot – which she uses in several different fashions. She can figure out the player's position and respond accordingly. If she's close to you, she'll lunge and try to tear you to shreds with her claws, alternating between a left hand claw animation and a right hand claw animation. If she's at a distance, she'll blast you with her laser. If she's above you, she'll go on a bombing run, circling like a vulture and shooting her laser beams. She even leads her fire.

I've tweaked the player's behavior. The hero will now smoothly aim her gun up and down, and, when strafing, aim forward instead of the direction she's moving. She can be knocked down by powerful enemy attacks. If she's flat on her back, she recovers with that stylish jump-flip sort of motion that ninja and martial artists are so fond of these days. If she's face down, she can roll to the side to avoid people fightin' dirty.

I've modified the status screen, or heads up display, or whatever you want to call it. The hero's life bar is very nifty now. It goes up and down as she takes damage or gets healing items, and it does so gradually – I'll show what I mean later if I feel like it.

I've also worked on the player's weaponry. She has two…no, wait, three…different ranged weapons, and I'm starting to work on her melee weapon.

Perhaps most importantly, I've gotten a firmer idea of how the game will work. I've come up with concepts for equipment that the player will get and how it will be used for combat, exploration, and puzzle solving.

But you're not here for a progress report, are you? I didn't think so. You want tips on how to make two different visual effects work in unity. I will provide…In the next two posts.

Saturday, November 5, 2011

Refuge in Audacity

So, recently I've been experimenting with the Skinned Cloth physics component in Unity.

The thing about Skinned Cloth is, it only interacts with the Mesh it's assigned to. If a character is composed of more than one mesh then the cloth will only collide with itself. In this case, if I separated the Seraph (more on her later) into one mesh for her skirt and one for the rest of her body, the skirt would be completely unaffected by the movements of her tail. This is, obviously, unacceptable.

If I make the Seraph a single mesh, I run into a different problem - a problem that I am all too familiar with, thanks to my experience assigning joint weights in Milkshape.

If you look at the screenshot above…well, you might see the problem. How easy do you think it would be to assign the various attributes that govern the behavior of cloth when I've got to select each vertex by hand, with the vertices of the Seraph's body getting in the way? Not very easy at all.

The solution to this problem is actually really simple. It's also something I'd never have the nerve to try a few years ago.

Simply open the file in Maya…

…and move the skirt away from the body.

Adjusting the properties of the skirt is now a piece of cake! Just select the vertices you want to modify and you're in business.

When you're done, return to Maya and move the skirt back into place.

 The great thing about Unity is that it cooperates with Maya. When I was modeling characters for Warcraft III the summer before last, this would not have worked at all. I had to use five different programs on two separate computers to model, texture, animate, and import each character, and these programs did not work together well. Taking a model from one program to the next was a tedious – and frequently irreversible – process. Adding new animations after bringing the model into the game was impossible. Altering geometry after skinning the model was nearly so.