Thursday, March 14, 2013

Back From Break and Phase 2

When I left for break I had just presented a nearly working version of my program in Unity. This week has been about tying up loose edges. The big project this week was making it so that the characters stopped and interacted in a way that wasn't instantaneous. That's been completed - I'm currently working on adding in animations that play when the characters are interacting based on the action (the action txt file has a line for animation file to be played). After that, I want to reimplement death (my characters can no longer die) and flesh out some more actions and emotions for testing purposes. That should take me through the weekend.

My big question now is what to work on next (Aline, if you're reading this, I'd appreciate your input). My two options are:

  • Dynamic camera that "cuts" to the most interesting part of the scene
or 
  • Interactive game where you control the "main" character and the story is generated around you as you play.
That'll determine what I spend next week doing and what my priorities will be going into the beta and final presentation. I hopefully will have time to do both, but both won't exist within the same version of my code (it doesn't make much sense to be cutting away from a player controlled character, after all). I can think of a number of pros and cons for both, but I'm currently leaning towards the dynamic camera first and interactive game second. It will probably take less time to do the dynamic camera, meaning I'd still have time to try the game, and it's more in keeping with my original goal - making a program that knows how to present the story.

Sunday, March 3, 2013

Screenshots Galore!

Characters have their names floating over their heads until they've had an interaction. Afterwards, their most recent interaction phrase (this character ______ another character) displays over their heads. Characters can have names specified in the config file (Montswana) or can be auto generated (Character 1, 2, 3, etc). Characters walk on random paths until they get close to another character.
Once close enough to another character, the two become "interaction partners" and plot courses towards each other.

Once interaction partners are within an interaction distance, they will stop until one of their actions exits out of the conversation. This will usually happen instantaneously at the moment, as all actions take only a tiny fraction of a second to complete, and so entire interactions are simulated in under a second. 


Whew!

Where to begin?

Following a meeting with Aline where she helped me through most of my biggest problems, all the pieces started falling into place one by one. First I got scene loading working, so that various characters loaded into the scene from the config file. Then I got actions and emotions back up and running, and defined the character object script so that it's more or less the same as the character class from the text based version of my code.

Once I got characters into the scene and walking around, I created a line of text above their heads and attached a script so that they follow the characters and always point towards the camera. I rigged up a script so that the number keys 1-9 correspond to characters 1-9 (technically characters 0-8), and 0 resets the camera so that it isn't attached to anyone. Eventually I will have the opportunity to "cut" using the camera from interesting scene to interesting scene.

Next I got character interactions back online, so that characters could interact with each other based on the config file (I still need to tweak the config file so that there are more interesting directions that conversations can go - right now positive gets more positive and negative gets more negative, without anything like "accidental insult" or the conversation getting dull or conversation ending actions that occur without extreme emotional settings). I made it so that characters find other characters that aren't interacting and walk to each other. Then I re-implemented actions, so that characters could have their interactions and then break away from each other. This made the characters end their interactions, but because they were nearest to the people they just interacted with, they would just start another interaction with those people. So I added a variable to keep track of past partners, so that partners wouldn't repeat (since you would never have a conversation with someone, end it out of boredom or frustration, and immediately start a new one with the same person). I made it so the text above characters' heads displays the action that they are implementing (the action lines from the text based version proved helpful here). I noticed two problems here - there was bunching occurring, where characters would walk to each other and eventually wind up in a cluster in the middle. The other issue was that there was no random wandering - characters just walked to the closest characters to them, interacted, then found the next closest and walked there. I tried to fix both these problems by having characters wander to random points on the screen and only "notice" each other - walk up to each other - if two unoccupied characters get within a certain radius of each other. When that happens, they lock on to one another and walk up to each other as before.

Some immediate next steps: there is still a bit of bunching going on, mostly I think because character interactions are instantaneous. Characters meet with each other and then bounce off. The actions need to have a time interval that they take. Right now, the interaction loop cycles through and implements different actions so that each character performs dozens in under a second, and then they go their separate ways. I need to try to condense this (each consecutive action gets folded into the previous one, each uninteresting action gets suppressed) so that we actually see the actions going on onscreen. After that, I need make it so that actions have corresponding animations (their config files currently have a spot for animation names, but I need to actually implement the code that takes those names and plays the animation). This will be relatively straightforward... Aline already taught me how to do that.

I anticipate things moving a lot faster from here on in. Now that I've got a solid understanding of how Unity works (and more importantly, a solid framework to build off of), it should be a matter of implementing feature by feature (for instance, I still need to reimplement death in the Unity file).

After this there are many ways I can go. My primary target is still turning this into a playable game, though Aline and Norm gave me a number of other targets I can try to meet along the way. One of these is having characters remember past interactions that they can "recall" upon request. In a game I could then ask someone "what did you just do?" and they'll recount their story to me in a complex way that factors in how long ago the action was performed and what its importance value was.

I'll post screenshots soon of what the project looks like right now.

Monday, February 18, 2013

Ten Steps Back

After working this weekend to try and come up with new config files to test, I've discovered that my Unity project is actually horribly broken and that any perceived progress this past week was actually a coincidence. I'm now planning on going back to the original walking person code and starting over with my code integration, hopefully with some help this time (I realize now it was stupid of me to stubbornly try to learn it on my own).

I'm getting really frustrated with Unity. My struggles with it have completely halted any progress on my actual project - the development of dynamic storytelling for games. I feel as though I'm no farther now than I was at the start of the semester - more than a month ago.

I have a little over a week now until the Alpha Reviews are due. I'm still deadset on having my code work in Unity by that deadline, which is a problem due to the fact that I'm starting over and clearly still don't understand the first thing about how Unity works. I've sent an e-mail to Aline asking if she has a few hours this week to try and help me with the code integration. I have a lot of ideas on how to integrate everything, but I don't understand the mechanics of how Unity works. Hopefully, with Aline's help I can get this done by next week. If not, I'm really not sure what the next step is. I don't want to waste any more time on the visualization of something I've had working for months now.

Thursday, February 14, 2013

Finally Some Progress

I really do think the Unity port is coming along, if still a bit slowly. At every turn I pretty much need to figure out "well, what's the Unity version of this?"

Since last week I had a talk with Aline, who seemed to think that the project would be much more impressive if I do manage to pull it off in Unity (which I agree with). She very graciously offered any help I might need (which I've yet to take her up on, with my oddly full schedule) and pointed me towards other people who might be able to help me (again, scheduling has been a nightmare this past week). Next week I might actually (finally) get the chance to sit down and get some one on one help, which is good because the Alphas are due the week after and I really want to get at least the simulation up and running in Unity.

I've been able to get the start script almost fully operational, loading various figures into my scene as well as creating new actions and emotions. I've got an idea of how to link the actions/emotions with the characters... Essentially, I need to rewrite my character script and attach it to my "actors" (the walking figures), which I've already done. I've hit a small snag in that once the characters are created I have trouble getting them to do anything. For example, I can create 5 characters and give them attributes based on my scene txt file, and I have a walking script attached to them that is controlled (again, in theory) by the designated "actions," but they don't actually walk unless they were created before initialization. Which is to say, I can attach scripts that control the figures to them, but I haven't yet figured out how to control my figures or access/activate their scripts once they've been created. I assume I'll be able to figure it out through my usual method - beat my head against the problem and Google it until I strike gold - but if I'm still stuck on this issue by Monday I'll likely be coming in to the SIG Lab to ask someone for assistance. Still optimistic about achieving my alpha goal! Will post photo results once I can actually get these guys to do something (instead of just theoretically being primed and initialized to actually do something).

That's it for now!

Thursday, February 7, 2013

Many Garys

I named my AdaptMan Gary. I'm not sure why.

Anyway, finally something to show. I was able to fix Unity and get a good enough understanding of it that I can now create multiple versions of Gary, though not in any way that's linked to the initial scenefile. I think I know how to handle that, though. It does require major restructuring, but it's more copy-pasting than rewriting from scratch and that's a good thing.

I think step one in Unity version of Storyteller will be "generate characters, get them to walk around". Step two will be "get them to stop and recognize each other" and step three will be "get the complete story thing working."

In the image below, the walking "Gary" was created before runtime. The other three Garys were created at runtime as a test, and in the next test (which will be performed tomorrow, because this has been a long day and I am tired), I will attempt to get them to generate in random (within reason) locations with names and numbers based on the scene file. Might be a bit too much to try and get done in one day given my luck with Unity lately, but I feel like this (no matter how trivial) represents a major breakthrough in my understanding of this program and hopefully will give way to better, faster breakthroughs in the future.


Unity Struggles

I've just been reading a lot about Unity lately. I know what Prefabs are now, and how I'll need them if I want to do dynamic anything in Unity. I know about how there's no main script I can use to control how the game is run, and I know that it's absolutely unlike any coding environment I've ever worked with before. I said earlier that I found Unity intimidating. Now that I'm starting to understand it, I find it terrifying.

Through my research, I've had the revelation that the way my code is structured is fundamentally not going to cooperate with Unity. Unity is object based in a very different way from the one I'm used to... Which is to say, while I have multiple objects all used and updated in the main loop of my main program file, Unity has no such main loop. I need to have each character keep track of themselves and update themselves on each step of the game loop in the game object's Update class, which basically means I have to tear down my code and rebuild it in Unity this time. Additionally, I've been having a bizarre amount of trouble trying to get the scene initialization to work, in addition to some other bizarre bugs. Trying to get Unity to work is really stressing me out, and I feel like it's been distracting me from what the focus of my project was supposed to be - dynamically generating stories for games. I've e-mailed Aline to see how bad the consequences would be for not using Unity, and choosing a more simple approach to a graphical display (maybe something in 2D). I'm not expecting much, though, as I was told implementing my code in Unity would be an important element since I first proposed the project.

I'm currently drafting what I think will work as a scene intializer (if I can get ever get my code to compile). In theory, it should read the scene file and add a number of characters to the scene, but that's it - I haven't been able to figure out porting emotions or actions just yet. That said, I'd be happy to get just this up and running for now. Unfortunately, as I said, my code still will not compile in Unity so I can't tell if I'm going about this the right way (it's not a code error as far as I can tell - Unity says it's missing some important files for compiling my file and I can't seem to find the error online. Weird, as this wasn't happening to me before).

I'll keep trying to get Unity to work until I hear back from Aline. At the very least, I'd like to sit down with her or someone who knows Unity better to help me sort through all this mess, because the learning curve has been much steeper than it was with C#. In writing this, I have actually thought of some ideas on how to proceed without rewriting absolutely everything (don't it always seem to go?), so I will continue to attempt to port my code into Unity, even though I've made virtually no progress in almost a month. I'm going to go ahead and try to get what I have to compile first, though. That seems like a good first start.

EDIT: Code compiles now! Thank you, internet!