Summary
The project that I did for my final consisted of a fight sequence between a player and their computer using the Kinect to track punches as well as blocks. What my project would do is simulate a game between them and the computer because like the player, the computer will fight back as well as block.
Technical
To make this work I had to first track the users skeleton using a Processing Patch written by Jesse Gilbert (my professor) that tracks the the body basically from head to toe (Here is what is needed to use this, there are instructions on the page for a simple install of OpenNI: Install Steps. Use this so that Processing could interact with Max OSC Download ). Once this was completed we used an OSC object to get the information that is being detected on the Kinect by the processing code. After that I created a sub patcher that holds the information of the range like x and y as well as z which is depth. For y patcher I used primarily the Z range because that detect how close a fist is to the Kinect. After I was able to set a range that sends a bang every time a fist goes beyond 0.2 of range.
To mimic a fighting game, I set a beginning time that does not allow the player or computer to hit until after 5 second. another way to mimic a game, I was able to create a life bar that decreases every time the Kinect detects a punch. After I was able to establish how the life bar would deplete (by subtracting 10 from from the life bar when a fist is in range) I wanted to create a blocking system so that it would even further be like a game. To do this I again used the Z depth but this time to detect how further is the leg. My blocking system is detected by putting your right leg back. I saw that wen people were playing this they were blocking ad punching at the same time and I believed that that was not fair so I used a ggate object to switch from blocking to hitting so if someone tries to punch while hitting it would not be possible to do damage. After I established everything that needed to be done for the user I started on the computer.
The computer was a lot less complicated in terms of creating punches and blocks. The computers runs of a metro which is basically a digital metronome which means that it could determine how fast bangs are given out. These bangs would be sent into a random number generator that is set to 50 so that it outputs 50 random numbers from the range of 0 to 49. In order to send out a punch I used what is called the select object which is an object that only sends out a bang when the random number generator (or whatever its connected to) reaches a specific number. I did this for both punches and blocks and like the user if the computer blocks it cannot hit you.
Once I had the fight system going, I created visuals so that the patch isn't plain. These visuals consisted of street fighter gifs that were turned into mov's (so that Max could read it). Each action had a corresponding video. For instance, a right punch would trigger a right punch video and so on. A problem with this is that I had to use a Rate atter UI to make the video play faster the reason that I did this is because people would punch so fast that the action on the video would not play all the way through. same thing goes for the computer which is still something I was not able to fix.
Something that i wanted to do with this patch was make it realistic and to do that I wanted the video to go back to a regular stance when either the computer or the player or doing nothing. which means that after a punch or a block the video would go back to its a original stance. To do this the toggle button was used. the toggle button has to numbers in it 0 (off) and 1 (on) using these 2 numbers I switched between an action and a stance pretty easily.After all the videos were fixed I recreated an end game that would not only stop the game but also play an end game mov. since the life bar has numbers for a range I used a select object for when the slider reaches 0. when the slider reaches 0 the patch stops by closing (setting to 0) all ggates and toggles but playing a video on both sides that is triggered only when the slider reaches 0. along with this a message with a 1 in it is sent to the Rate atter UI so that the end game is played at normal speed.
Inspiration
I was inspired by this Street Fighter Kinect Hack because this person was able to do everything that I was trying to do but he used something else. He was able to fight with his body and create super moves and i wanted to do that to but i do not believe that I would be able to do that at least not yet. But thanks to this I was able to get the ball rolling into creating my patch. Which I called Comp Fight, Enjoy.
Future
For the future I want this patch to be able to support imported 3D characters like from Maya. I would like to see people use my patch to import there characters that they created and play using my patch and also i would want to make this a 2 player game. To do this I would have to find the range of the arm and legs using the model itself and the person themselves as well as create a completely separate patch for the second player which i do not know how to do yet. This was originally the idea for my project but proved to be too problematic due to changing conditions of the patch but ultimately this is my goal and I would wish to see it through.

No comments:
Post a Comment