Showing posts with label Unity. Show all posts
Showing posts with label Unity. Show all posts

Sunday, May 19, 2013

OpenInFileBrowser Code

I realized there's a debacle right now in the Unity Wiki Website over its content being under the Creative Commons License.

So to make sure there's no legal problems with using this code, here's a re-upload of my OpenFileInBrowser code for Unity here in my blog.

As always, I put this code in Public Domain as it's quite simple but good enough to be shared.


public static class OpenInFileBrowser
{
   public static bool IsInMacOS
   {
      get
      {
         return SystemInfo.operatingSystem.IndexOf("Mac OS") != -1;
      }
   }
 
   public static bool IsInWinOS
   {
      get
      {
         return SystemInfo.operatingSystem.IndexOf("Windows") != -1;
      }
   }
 
   [MenuItem("Window/Test OpenInFileBrowser")]
   public static void Test()
   {
      //string path = "/Users/Ferds/Unity Projects/BuildReportTool/BuildReportUnityProject/Assets/BuildReportDebug";
      //string path = "/Users/Ferds/Unity Projects/BuildReportTool/BuildReportUnityProject/Assets/BuildReportDebug/EditorMorel.log.txt";
      //string path = "/Users/Ferds/UnityBuildReports/";
      string path = "/Users/Ferds/UnityBuildReports/test4.xml";
 
      Open(path);
   }
 
 
   public static void OpenInMac(string path)
   {
      bool openInsidesOfFolder = false;
 
      // try mac
      string macPath = path.Replace("\\", "/"); // mac finder doesn't like backward slashes
 
      if (Directory.Exists(macPath)) // if path requested is a folder, automatically open insides of that folder
      {
         openInsidesOfFolder = true;
      }
 
      //Debug.Log("macPath: " + macPath);
      //Debug.Log("openInsidesOfFolder: " + openInsidesOfFolder);
 
      if (!macPath.StartsWith("\""))
      {
         macPath = "\"" + macPath;
      }
      if (!macPath.EndsWith("\""))
      {
         macPath = macPath + "\"";
      }
      string arguments = (openInsidesOfFolder ? "" : "-R ") + macPath;
      //Debug.Log("arguments: " + arguments);
      try
      {
         System.Diagnostics.Process.Start("open", arguments);
      }
      catch(System.ComponentModel.Win32Exception e)
      {
         // tried to open mac finder in windows
         // just silently skip error
         // we currently have no platform define for the current OS we are in, so we resort to this
         e.HelpLink = ""; // do anything with this variable to silence warning about not using it
      }
   }
 
   public static void OpenInWin(string path)
   {
      bool openInsidesOfFolder = false;
 
      // try windows
      string winPath = path.Replace("/", "\\"); // windows explorer doesn't like forward slashes
 
      if (Directory.Exists(winPath)) // if path requested is a folder, automatically open insides of that folder
      {
         openInsidesOfFolder = true;
      }
      try
      {
         System.Diagnostics.Process.Start("explorer.exe", (openInsidesOfFolder ? "/root," : "/select,") + winPath);
      }
      catch(System.ComponentModel.Win32Exception e)
      {
         // tried to open win explorer in mac
         // just silently skip error
         // we currently have no platform define for the current OS we are in, so we resort to this
         e.HelpLink = ""; // do anything with this variable to silence warning about not using it
      }
   }
 
   public static void Open(string path)
   {
      if (IsInWinOS)
      {
         OpenInWinFileBrowser(path);
      }
      else if (IsInMacOS)
      {
         OpenInMacFileBrowser(path);
      }
      else // couldn't determine OS
      {
         OpenInWinFileBrowser(path);
         OpenInMacFileBrowser(path);
      }
   }
}

Wednesday, May 8, 2013

My first time selling on the Unity Asset Store

It started with this. Someone was having trouble with his build size so I explained that thing about the Editor.log, in that it actually had info on the breakdown of your build's file size!

So I went and whipped up a simple front-end for the log's build info over a weekend.


Then I asked the forums if they'd be interested in having it on the Asset Store. A handful of people agreed. Then I thought, why don't I try selling it, maybe for just a few bucks to see what's the experience of selling on the Asset Store? We need the money anyway.

There was a discussion in a LinkedIn Unity group where someone was adamant that I should give it for free and that I'd only get a few bucks out of it. It was quite a bummer. It was a bit depressing actually.

So I set it to $2 as an introductory price and waited how it would turn out. The plan went that I'd keep it as $2 for one week then set it to the standard price.

David Helgason even retweeted my tweet about it. I guess it was like... I don't know. Stevie Wonder humming a tune you just made up? It was unexpectedly cool.

David's a pretty awesome guy.

I placed a public poll on my forum thread asking "How much would you be willing to pay for this plugin?" The choices I put where $2, $5, and $10. Majority answered $5. I guess they're not that cheap that they'd settle for the lowest price. Seems like $10 is too much too. So we figured $5 was the sweet spot.

By the end of the week I then set it to $5, only to realize that price changes do, in fact, still have to go through review by the Asset Store team. Then David again helped me out. It's quite awesome that a big company like Unity still has the time to help out the little guys using their products.

So the $2 sale went for approximately 9 days. A total of 117 people bought it during that period.

I'd shudder to think that $163 is only a few bucks. Must be there's a really high standard of living where that guy is.

Now that the selling price is $5, the amount of people who purchased is about 1/3rds lesser. I still got higher sales overall though.

It's selling quite well, for something I just whipped up over the weekend (though I do improve it every now and then). It's managed to get consistent five stars from reviews. It even got to the Asset Store front page one time.


Here's the link to the Asset Store page: http://u3d.as/4u2

Here are some things I'd like to share for my experience:

  1. If a customer previously purchased directly from you (not from Asset Store), it cannot be unlocked for them in the Asset Store for free. They have to buy it again in the Asset Store.
  2. Your publisher page is quite bare-bones. There's no sales graph or overall total sales. There's only the sales per month, and you can only view one month at a time. Switching from one month to the next is quite slow (for my Internet connection).
  3. Related to that, when a customer posts a user review, you get no email notification about it, or any notification whatsoever. You have to visit your asset store product's page every now and then to see if someone has a complaint in their review, or some misunderstanding you'd like to clear up. UT's take on this is that it's your job to facilitate communication with your customers, but something like an option for email notification in this case would be nice, no?
  4. The ways you could offer support is usually via Twitter, email, tell them that they can PM you in the Unity forums, or if you have a forum thread about your product, give them a link. You'd usually put such links in your Asset Store product page's description.
  5. I'd like to reiterate the standard warning: If enough customers complain that they are not getting adequate support from you, UT has the right to take down your product.
  6. If your product is something visual, then potential customers will like to see video demos, or web interactive demos to see an example of how your product is useful. Their mindset is: "So what's this Asset Store package? Will it be useful in the project I'm working on?" That second question is what you need to address. And you do it by showing potential scenarios of how it's used, i.e. demos.
  7. If your product is purely code instead, perhaps a video tutorial how to use it can also work. At the very least, post some screenshots. Surely there's something visually presentable that you can show?
  8. If your asset store package has code, customers will appreciate it if you separate your code into your own namespace as much as possible to avoid name conflicts.
  9. Use the lowest possible version of Unity when releasing your asset package. Since they are distributed as .unitypackage files, the version of Unity used to create the .unitypackage is also the lowest version allowed to import that file. Frankly, I think this is just a conspiracy to force you to upgrade your licenses. I keep an installation of Unity 3.5.3 in this case.
  10. Selling on the Unity Asset Store is a non-exclusive deal. I.e. you are free to sell your product via other stores (ex. gameprefabs.com)
  11. You can't verify if a person who emailed you really purchased your product just using your publisher dashboard alone. You can, however, email the Asset Store Team to verify for you if someone indeed purchased it. Dantus in the Unity forums points out email isn't necessary. All you need to do to verify if someone purchased your asset is to ask them for their Invoice Number. Then in your publisher dashboard, there's a tab called "Verify Invoice". You can type the Invoice Number there to verify someone's purchase. (For example, say, someone reported a bug. So you fix it and would like to send it to the bug reporter to test the fix on his machine. What if he didn't really purchase your product? You better verify to be safe.)
  12. Possible places you can use to advertise your asset package:
    1. Main Unity Forums
    2. Google+ Unity Community
    3. LinkedIn Unity Group
    4. Unity South East Asian Mailing List (only if you're based in South East Asia!)
    5. Unity3d Subreddit


Thursday, November 29, 2012

Battle Maiden Part 2

Day 2: Saturday

Fixed shoulder joint twisting.


Had to leave early because like mentioned, it suddenly turned out to be cleaning day.

It turns out Saturday was also when the meetup for the Game On! Philippines 2012, a game development competition for students. Me being one of the mentors for the participants, and that day was when the participants would meet with the organizers to show progress on their game, I attended the meeting to talk with the participants.

I'll talk about that some other time, but long story short, I wasn't able to do much progress on day 2.

Day 3: Sunday

Got things set up back at home. It's kinda hard to get back to the rhythm since the 48 hour hackathon didn't push through.

Suddenly I'm having crash problems with my Unity.

Every time I click "Apply" on changed prefab settings, there seems to be a 2 out of 3 chance that Unity will crash.


I guess it's because I'm using an old version, 3.5.5f2. So I tried finding 3.5.6, the latest one in the 3.x versions.

The official Unity site, for some reason, doesn't show the links to older versions of Unity. Since Unity 4 is out, this means there's no links to any 3.x versions.

I had to find it from the forums, and even the site had problems.


Dark forces are at play here.

When I finally got to it, the download is slow, as expected. Oh Asian Internet, you so crazy.



It would have been nice to just press Ctrl+S in the Unity editor and be assured that everything was saved in case a crash happens again.

Unfortunately, this isn't the case. When you change settings in prefabs, or GUI skins, or ScriptableObject files for example, Unity holds off saving the changes to the disk until you quit Unity. So I find myself closing and opening Unity after every significant change I make.


Meanwhile, I got the Locomotion system working a little more smoother and I got to test the player model in the game.



Times like these I wish we had motion capture studios. I heard you can use a Kinect as a low-cost makeshift motion capture device.

Day 4: Monday

Have I mentioned that I go to the office only when I feel like it? Yeah, so Monday will be devoted to finishing this, because I say so.

Day 5: Tuesday

Have I mentioned I rarely ever get any work done while at home? Yeah, so I slept all day long yesterday. But I was able to test attack animations today.





Also, seems like the version update for Unity got rid of the crashes.

Day 6: Wednesday

I did a few thumbnail sketches so I wouldn't forget what animations I wanted to do. I should've done this earlier.


Right now the game is sort of on-hold as Wednesday is usually the time I go to the office.

Wednesday, November 28, 2012

Battle Maiden Part 1

In the small game development studio I work in, I wanted to have what we ended up calling "Free Fridays": Every first Friday of the month, everyone stops doing work for clients and make personal projects. At the end of the day, you show your work to everyone.

This was an excuse to find the time to do crazy ideas that we get every now and then.

One such idea came to me when I was about to sleep, I just thought all of a sudden "Damn it, I want to play Assassin's Creed style combat right now on my Android tablet."

I thought, yeah that could work. I actually like the easier, free flow approach in Batman: Arkham Asylum. Batman can dart from one end of the arena to the next so easily, hitting opponents here and there.

H-Here We Go


So when our Operations Director mentioned we forgot to do Free Fridays again for this month, I thought I'd do that idea.

I also requested that Free Friday be lengthened to 48 hours (up to Saturday), since the idea I had was a lot of work. Game jams are mostly 48 hours anyway.

Even with the extended duration, I knew I had to cheat a little. I'm only one guy doing both code and art so 48 hours was probably still not enough.

Day 0: Wednesday-Thursday


I stole some time from work to prepare the 3d models I'd use. For the enemy I used the soldier model I already made from before.



For the player, I used MakeHuman to create a base mesh, then added hair and clothes in Blender.

I did this with the understanding that I'm making a throwaway model just so I can finish this as soon as possible. While her face shouldn't be anime like my old sketches, it shouldn't be the one that MakeHuman comes with either.



I downloaded a bunch of Assassin's Creed 2 and Batman Arkham Asylum YouTube videos for reference.



The idea was that we'd start at 00:00 of Friday and end at 23:59 of Saturday, to really squeeze the 48 hours. It wouldn't be wise to extend to Sunday, and the higher-ups didn't want us to start earlier than Friday.

So by about 1 AM of Friday, I was still preparing the player 3d model. I had a headache and felt like vomiting (as always when I stay too long in the office), so I had to sleep it out.

Day 1: Friday


By morning I was ready to tackle it on.

This was my first draft for the ideas.



I thought I'd try Unity 4 with all its fancy new animation systems with the blend tree. Hopefully that would make my work easier.

As I tried getting myself accustomed to the GUI changes in Unity 4, this happens.



I can't rely on a tool that crashes, given that I have a tight deadline for this, so off I went back to Unity 3.



These were my first few tests:

I wanted a way for the enemies to figure out the path to get to the player's backside. I also wanted them to move in an encircling fashion. So I made a simple waypoint system to track the player's front, back, left, and right sides.



Next I had the enemies actually follow that path.



By afternoon, I swapped in the enemy 3d model. I used Rune Johansen's Locomotion System to make the walk animations look better. Props to Rune!



Unfortunately we were suddenly told that Saturday can't be used anymore because the office will be cleaned. I guess I just have to take my work home or something.

To tell the truth though, not a lot of people in the office was taking Free Friday very seriously. Some understandably still had deadlines to meet and some were just playing videogames.

I actually still needed to fix the player 3d model. It wasn't even rigged/skinned yet, so I ended up taking too much time there.

I wanted a lot of fancy physics effects on the player. The skirt and ponytail should sway, and her boobs should *ahem* move naturally.

For cloth swaying, Unity has the built-in Skinned Cloth component for that and it works as expected. The interface to configure it isn't exactly great, but it works as advertised.



Doing the same thing for the ponytail would be overkill, and besides, it should move more like linked pieces of elongated chains than like a strip of cloth anyway.

I found a link in reddit that explains a simple trick, just use rigidbodies with joints on them and add some swaying motion: http://www.farfarer.com/blog/2011/07/07/unity-skeletal-ragdoll-jiggle-bones-tutorial/

The only problem was that the tutorial needed me to configure my 3d modeling software to specifically disable keyframe animation on the bones that need to jiggle. Unfortunately, no such option exists in Blender, so I just did something quick to fix it.

I made a script in Unity that detaches the ponytail's bone from the skeleton then reattach it again quickly. This would cause it to stop being moved by the skeleton's animations, while still being connected to it.

For the boobs, the wiki site has something just for that: http://www.unifycommunity.com/wiki/index.php?title=JiggleBone

The code for that needed some cleaning up and it didn't seem to work reliably at all for a 3d model created in Blender, so I took some time to fix it.

The day ended with me staring at bouncing boobs.





While I feel a little stupid for doing this, I made pretty sure the physics don't go so far as this:



Damn, I haven't even added combat yet.



Friday, February 3, 2012

Tactics Ensemble: Movement

This is an experiment on the movement mechanic of the combat for Victis.


The violet area is the limits of where the tiny white guy in the middle can move to.

While the game is turn-based, the map does not make use of grids. Basically I just used my idea from Death Zone Zero, which in turn, got its idea from RTS games in general. If you've played tabletop wargames, things work that way.

Movement is calculated as a stamina cost per meter, not a predefined value. He has, in this example, 100 stamina points, and movement is 2 stamina points per meter.

Other actions like attacking also consumes stamina, so the player has to be mindful of deciding when to conserve stamina for movement or actions. Basically the same with Action Points of XCOM games.

Furthermore, climbing upwards has a higher stamina cost of 10 stamina points per meter, which accounts for the irregular shape of the movement range.

The currently selected destination is shown with the X-mark on the ground there, with the distance to that shown at the top left, together with the total stamina cost to move there. You can see the stamina cost is roughly twice the distance. This is correct since again, I've set it to be 2 stamina points per meter. The disparity is from the fact that the terrain is bumpy, and since climbing upwards is more costly, the destination's stamina cost reflects this.

Tuesday, January 31, 2012

Input Recorder For Unity

Being able to record player input is invaluable for bug reports so players can submit their recorded play session and you can easily watch how the bug manifests.

After development, its also useful for the end-user to share his play experience to other people, or to allow other people to study other player's tactics.

So I saw this:


And saw how simple the input display was. So I went to try the same thing in Unity:


This only records input so far. Feeding those recorded input back to the game is another matter. Its also not possible to feed those data back into Unity's input system as far as I know. So I can't make Input.GetAxis() return the recorded input data.

Instead I would have to make my own system, like, say, RecordedInput.GetAxis(), RecordedInput.GetButton(), and so on. Feeding that data to the GUI system is also another matter.

Monday, December 19, 2011

Collaborative Diffusion/Influence Maps For Obstacle Avoidance

There was in the Unity forums, a post asking about how to implement flanking behaviour obstacle avoidance. I took interest because I've been wondering how to do that also.

Another user posted a link to a page explaining Collaborative Diffusion. From what I understand, its like influence maps, but once an agent passes through a node, that node's influence becomes zero, signifying its impassable now that he's there.


So I tried implementing it in Unity here: http://dl.dropbox.com/u/25260770/PathfindingTest/WebPlayer.html (you'll need to install the Unity plugin for your browser).

Left click to set the new attraction point or whatever its supposed to be called.

I'm pretty sure some of my code is a bit naive. Its only in certain situations do the agents will exhibit flanking behaviour. Some agents end up stuck, and I don't like the bee-like zig-zag movement they make.

Also I think it would be better to couple this with typical A*, such that, the path created by the A*, the area of the influence map that that path takes up, will be set to zero influence. Its as if the agent will be saying "to my allies, this is the path I'll take, don't cross it, its mine only. find your own path".

Monday, August 15, 2011

Blending Problems

So I got these indicators to know when a unit is selected or where he's going to move:


Its a projector, its not the fastest, but it looks good. Its blend equation is set right now to multiply. That's fine but:


Multiply darkens the blend, making it hard to see in dark places. So, I try an additive blend:


So that looks better. Only it does the opposite: in bright areas, its hard to see:


More so in very bright areas:


So in the end, I am forced to use a normal alpha-blend equation. It looks plain, but is sure to be visible in both bright and dark areas:



Unfortunately, you can't emulate the blend types in Photoshop like Overlay, because blending equations in videocards are fixed-function.

Here's the Unity shaderlab code for alpha-blended projectors:

Shader "Projector/Diffuse" {
	Properties {
		_Color ("Main Color", Color) = (1,1,1,1)
		_ShadowTex ("Cookie", 2D) = "" { TexGen ObjectLinear }
	}
	Subshader {
		Tags { "RenderType"="Transparent"  "Queue"="Transparent"}
		Pass {

			ZWrite off
			Fog { Color (0, 0, 0) }
			Color [_Color]
			ColorMask RGB
			Offset -1, -1

			Blend SrcAlpha OneMinusSrcAlpha

CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_fog_exp2
#pragma fragmentoption ARB_precision_hint_fastest

#include "UnityCG.cginc"

sampler2D _ShadowTex;
float4x4 _Projector;
fixed4 _Color;

struct v2f {
	float4 vertex : SV_POSITION;
	float4 texcoord : TEXCOORD0;
};

v2f vert (appdata_tan v)
{
	v2f o;
	o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
	o.texcoord = mul(_Projector, v.vertex);
	return o;
}

half4 frag (v2f i) : COLOR
{
	return tex2Dproj(_ShadowTex, UNITY_PROJ_COORD(i.texcoord)) * _Color;
}
ENDCG
		}
	}
}

Wednesday, August 10, 2011

MeleeWeaponTrail: Another Unity Asset Store Submission

This is my second Unity Asset Store submission, a weapon trail effect for your character attacks. Props go to Forest Johnson (Yoggy) and xyber for the original code.



You can find the wiki page here: http://unifycommunity.com/wiki/index.php?title=MeleeWeaponTrail

UPDATE: Asset Store submission accepted! http://u3d.as/content/anomalous-underdog/melee-weapon-trail/2ck

Web build demo here: http://dl.dropbox.com/u/25260770/MeleeWeaponTrailDemo/WebPlayer.html

Tuesday, April 5, 2011

Tuesday, March 15, 2011

Stuff: A news aggregator in 3d

http://anomalousunderdog.herobo.com/Unity/Stuff/

A work-in-progress 3d RSS reader, similar to the RSS Visualizer in Mac OS X. More than this, its planned to also slideshow showing Twitter tweets, time of day for different countries, images from a folder/website (demotivational posters, wallpapers, etc.), text from a folder/website (word of the day, etc.), weather data, and even perhaps video podcasts.

I originally envisioned this to be displayed in a large LCD screen in our office.

Thursday, March 10, 2011

HHHhUUUUuRRRrrrRRrrRRRRR! A RECKLESS DISREGARD FOR POLYCOUNT


"I'd check it out, but I have to install some shitty plugin. 0/10."
- Anon

Your framerate is your life. In HHHhUUUUuRRRrrrRRrrRRRRR, you fight badly created 3d models in a never-ending effort to bring your framerates to an acceptable value.

HHHhUUUUuRRRrrrRRrrRRRRR is a non-work project I'm making in my free-time. Only a work-in-progress main menu intro animation has been uploaded so far. Check it out here: http://anomalousunderdog.herobo.com/Unity/Hurrr/

Monday, March 7, 2011

Back To The Oct 29 2099

Check it out, my first try at uploading something to the Unity Asset Store. Its pending review but here it shows the preview of what it'll look like back... to the future!



UPDATE: Here's the link: http://u3d.as/content/anomalous-underdog/unity-lua-interface-library/1AY

Sunday, January 30, 2011

I am not your mom

Jan 30 17:49:32 <Tayfe> AnomalusUndrdog: mom, maybe i found the problem...
Jan 30 17:49:51 <AnomalusUndrdog> I am not your mom
Jan 30 17:50:03 <VILE> lol
Jan 30 17:51:04 <Tayfe> AnomalusUndrdog: mom - one moment pls^^
Jan 30 17:51:19 <AnomalusUndrdog> I am not even female
Jan 30 17:51:36 <Tayfe> AnomalusUndrdog: maybe it's a problem that i use the same code on the car, too?

Oh IRC chat, you so crazy.

Join in the fun: #unity3d in freenode.

In other news, from the same IRC chat, I just learned about partial classes. A way to split your class definition into separate files, which is what I did back in C++ Torque days as my classes get to be too big. In most situations, this is doing it wrong, because classes getting big is a sign that I'm putting too much functionality in one place and I should separate distinct functionalities into separate classes in the first place.

Saturday, November 6, 2010

I'm not dead yet

Sorry for the lack of posts lately. Long story short, I decided to get a full-time job in game development so my personal projects are shelved for the time being.

The company I work in, Dreamlords Digital, decided to use my test game, Zombie Fields, as an actual commercial game. So now I'm working on porting it to the iPhone and adding lots of polish.

A few, old, work-in-progress screenshots:



I'm actually grateful that the company I now work for allows me a lot of creative freedom.

Tuesday, July 20, 2010

Death Zone Zero: Minor Update: Zone Lobby Gui

One thing I really hate about Unity is the lack of better GUI functions, something that would make use of the Model-View-Controller pattern, because right now, almost everything is done in code.

It took me quite a while to code a popup menu (aka context menu/right-click menu).

Tuesday, July 13, 2010

Death Zone Zero: Update: Zone Lobby

Photobucket

Players can now log-in to the zone lobby. This acts as a lobby area where players can meet up, chat, and challenge each other. So far you can only chat and move your avatar though.

Friday, July 2, 2010

Death Zone Zero: Update: Client Server Network



Here's a more complete test PVP match showcasing the abilities of all the units made so far.

Monday, June 21, 2010

Death Zone Zero: Update: Client Server Network



So here the client/server network is being shown, you can select units, move them, and attack them, and it all happens on the network.