Monday, March 18, 2019

Project Roadmap


Project Roadmap

I have revised last week's plan of action a bit to account for what I accomplished this week, and what I plan to accomplish in the weeks following:

- Week 7: 

  •  Character's rig completed
  • Reviewed re-targeting MoCap animations in Motion Builder
  • Learned how to use Unity Mecanim for editing and re-targeting animations.
  • Learned how to change root motion of animations in the inspector upon import, as well as in the Animation editor window.


-Week 8: 

  • Re-targeted all animations and got them into Unity.
  • Used Unity IK to bind left hand to rifle.
  • Used blend trees to blend between running in different directions.
  • Used animation layers to mask lower body running animations, and upper body running and shooting animations.
  • Restructured project, separating animation libraries to separate Unity project, for organizational purposes and to free up space in project.
  • Tried to add melee attack animation blend tree, which is still buggy. I may need to simplify it a great deal.


-Week 9: 

  • Re-imported all fixed Animations into Unity
  • Added jumping and landing animation and functionality. The Character now has a takeoff jumping, midair jumping, and soft landing animations. 
  • When the space bar is pressed or held, the character somersaults into the air. Holding down the space bar causes the character to somersault in the air for a longer period of time, and ascend to a greater height before being pulled back down to the ground.
  • Used Unity IK to begin adding aiming functionality. Character now aims forward, but additional animation correcting is required.

-Week 10:
  •  Continued working on jump and landing functionality.
    • Added hard landing animation, for a total of 2 different landing animations.
      • Still buggy
    • Added animation for jumping while shooting, a falling idle where avatar masks are used to transition the upper body from falling/airborne to shooting while falling/airborne.
    • Worked on fixing jumping animation problem/glitch:
      • Build functionality to detect how high character is in the air in order to smoothly transition between falling and landing animations. 
      • Calculated the rate of change in falling velocity based on how high the character is in the air, or use raycast, to determine when to start blending from falling to landing animation.
        • Still buggy.
  • Began building melee attack functionality
-Week 11:
  • Work on fixing jumping animation problem/glitch:
      • Continue building functionality to detect how high character is in the air in order to smoothly transition between falling and landing animations. 
      • Calculate the amount of force applied before jumping, based on a set of parameters.
      • Calculate the rate of change in falling velocity based on how high the character is in the air, or use raycast, to determine when to start blending from falling to landing animation.
  • Use IK to move fist to contact during melee attack animation.
  • Begin adding functionality for detecting when character should touch a nearby wall.
  • Look at smoothly blending IK weights to achieve smooth transition between IK handle control and animation.
  • Use IK to achieve foot planting (lowest priority)
  • Continue building aiming system, rotate spine bones (spine, chest, neck, head) to follow target.
  • If all of the above goals are completed, work on the Week 11 tasks in the spreadsheet:
    • Wall jumping
    • Ledge grab
    • Bullet stopping
  • Add as much functionality as possible in time remaining using all Unity Mecanim tools possible.
  • Continue working on character controller, adding more functionality. Add Unity IK functionality, troubleshoot problems if need be.

Wednesday, March 13, 2019

Project Roadmap


This is my updated task plan for the remainder of this quarter. I may cut certain items from this list in the event that I have over-scoped. Items that are lower priority are certainly at risk to be cut.

Going Forward

I have revised last week's plan of action a bit to account for what I accomplished this week, and what I plan to accomplish in the weeks following:

- Week 7: 

  •  Character's rig completed
  • Reviewed re-targeting MoCap animations in Motion Builder
  • Learned how to use Unity Mecanim for editing and re-targeting animations.
  • Learned how to change root motion of animations in the inspector upon import, as well as in the Animation editor window.


-Week 8: 

  • Re-targeted all animations and got them into Unity.
  • Used Unity IK to bind left hand to rifle.
  • Used blend trees to blend between running in different directions.
  • Used animation layers to mask lower body running animations, and upper body running and shooting animations.
  • Restructured project, separating animation libraries to separate Unity project, for organizational purposes and to free up space in project.
  • Tried to add melee attack animation blend tree, which is still buggy. I may need to simplify it a great deal.


-Week 9: 

  • Re-imported all fixed Animations into Unity
  • Added jumping and landing animation and functionality. The Character now has a takeoff jumping, midair jumping, and soft landing animations. 
  • When the space bar is pressed or held, the character somersaults into the air. Holding down the space bar causes the character to somersault in the air for a longer period of time, and ascend to a greater height before being pulled back down to the ground.
  • Used Unity IK to begin adding aiming functionality. Character now aims forward, but additional animation correcting is required.

-Week 10:

  • Continue building aiming system, rotate spine bones (spine, chest, neck, head) to follow target.
  •  Continue working on jump functionality.
    • Add hard landing and rolling animations, for a total of 3 different landing animations.
    • Add animation for jumping while shooting, a falling idle where avatar masks are used to transition the upper body from falling/airborne to shooting while falling/airborne.
    • Fix jumping animation problem/glitch:
      • Build functionality to detect how high character is in the air in order to smoothly transition between falling and landing animations. 
      • Calculate the amount of force applied before jumping, based on a set of parameters.
      • Calculate the rate of change in falling velocity based on how high the character is in the air, or use raycast, to determine when to start blending from falling to landing animation.
  • Use IK to move fist to contact during melee attack animation.
  • Begin adding functionality for detecting when character should touch a nearby wall.
  • Look at smoothly blending IK weights to achieve smooth transition between IK handle control and animation.
  • Use IK to achieve foot planting (lowest priority)

-Week 11:
  • If all of the above goals are completed, work on the Week 11 tasks in the spreadsheet:
    • Wall jumping
    • Ledge grab
    • Bullet stopping
  • Add as much functionality as possible in time remaining using all Unity Mecanim tools possible.
  • Continue working on character controller, adding more functionality. Add Unity IK functionality, troubleshoot problems if need be.
  • Master's thesis research, read articles, find new ones, post to blog. What am I doing for my master's thesis? Why? How will this advance the given field?

Sunday, March 10, 2019

Further Work on Aiming and Jumping

Here, I demonstrate my jumping mechanic and rifle aiming. Both are still in progress, this is an update to show the advancements that have been made so far.

I have used Unity IK to correct the position of the characters hands and rifle while aiming, so that he aims completely forward, in the direction of the camera. Some additional work is required because his hands freeze in that position, which looks awkward, and his torso also needs to be rotated to match where the rifle is aiming. There is also no rotation in the Y axis, and no animation for when he is idle and turning left and right with the camera. I will fix those issues as well to create a more animated character.



I show here my character in a test environment, downloaded from the Unity Asset store. This is just to have scale reference, and to also be able to see how fast he is moving, how high he is jumping, etc. This is where I demonstrate my jumping mechanic so far. He now falls faster and can jump higher or lower depending on how long the player holds the space bar. I still plan on adding two more types of landing, the hard landing, and rolling. I will also add jumping in all directions, because right now he only jumps forward. In addition, a shooting midair idle animation that can be transitioned to while the player is somersaulting through the air is needed.


Cursor Locked Mode

In Unity, you can lock the state of the cursor while in play mode, effectively turning the cursor invisible and constraining it to the center of the screen so that you don't accidentally click on anything while playing, which can happen often and is very problematic. Being able to lock the cursor is very helpful for both playing and testing games. These are the two lines of code that do the trick, tough some additional scripting may be required:

  1.         lockMode = CursorLockMode.Locked;
  2.         Cursor.lockState = lockMode;

Additional resources on cursor locking in Unity and other cursor modes:
https://docs.unity3d.com/ScriptReference/CursorLockMode.html
https://docs.unity3d.com/ScriptReference/Cursor-visible.html
https://forum.unity.com/threads/disable-mouse-cursor-in-windows-during-play-mode.387416/

Friday, March 8, 2019

Week 09 Progress

As you may see, my rifle fast mobile animations have been corrected, so that the rifle butt no longer clips through the character's chest while running.



My character now has jump animations. There are three animations that contribute to this jump effect total. There is an initial jump takeoff, which is hard to see at first glance, but it is there. It will take some more testing to get the transition time right. It took a bit of finagling with the speed of the animation and the transition time to get it visible. In most games, jumping is instantaneous. In others it is not, and there is an initial takeoff animation, which delays the time to jump after the key is pressed. This was difficult because I was trying to achieve the best of both effects, an instantaneous jump with a takeoff animation. Next, is the somersault/hover animation. This can be any animation that evokes free-fall or jumping in the air. For now, I chose to do a somersault. Lastly, is the landing animation, which is only the soft landing at the moment. I wish to expand this to three different types of landing: soft, hard, and rolling. The soft landing animation will play when the distance the character is falling is not too high. When the character falls from higher up, the hard landing animation will play. Finally, if the player presses the Ctrl key before impact, the rolling animation will play. 



Aiming is being corrected with Unity IK. I added to my IK solving script, which now controls the right hand. When the left mouse button is clicked, the character raises his rifle to aim directly in front of him. I plan to add to this my making the mouse control the rotation of the character's spine bone. I will also set up a blend tree for aiming up and down, and animations for turning left and right.


Thursday, March 7, 2019

Project Roadmap


This is my task plan for the remainder of this quarter. I may cut certain items from this list in the event that I have over-scoped. Items that are lower priority are certainly at risk to be cut.

Tuesday, March 5, 2019

Going Forward

I have revised last week's plan of action a bit to account for what I accomplished this week, and what I plan to accomplish in the weeks following:

- Week 7: 
 Character's rig completed

 Reviewed re-targeting MoCap animations in Motion Builder

Learned how to use Unity Mecanim for editing and re-targeting animations. Learned how to change
root motion of animations in the inspector upon import, as well as in the Animation editor window.

-Week 8: 
Re-targeted all animations and got them into Unity.

Used Unity IK to bind left hand to rifle.

Used blend trees to blend between running in different directions.

Used animation layers to mask lower body running animations, and upper body running and shooting animations.

Restructured project, separating animation libraries to separate Unity project, for organizational purposes and to free up space in project.

Tried to add melee attack animation blend tree, which is still buggy. I may need to simplify it a great deal.

-Week 9: 
Re-import all fixed Animations into Unity, Continue building state machines and get all animations to play on key press, animation layers, start building character controller, adding functionality.

Build aiming system, rotate spine bones (spine, chest, neck, head) to follow target.

Continue working on character controller, adding more functionality. Add Unity IK functionality, troubleshoot problems if need be.

Master's thesis research, read articles, find new ones, post to blog. What am I doing for my master's thesis? Why? How will this advance the given field?

-Week 10:
Add as much functionality as possible using all Unity Mecanim tools possible.

Fri-Sat--Master's thesis research, read articles, find new ones, post to blog. What am I doing for my master's thesis? Why? How will this advance the given field?

-Week 11:
Add as much functionality as possible in time remaining using all Unity Mecanim tools possible.

Fri-Sat--Master's thesis research, read articles, find new ones, post to blog. What am I doing for my master's thesis? Why? How will this advance the given field?

Monday, March 4, 2019

Getting "Apply Root Motion" Checked and Re-Structuring My Project


I had "Apply Root Motion" unchecked. That was causing some problems as we saw before. There were two main problems that I was having when apply root motion was checked, First, the camera would spin like a carousel around the character when running and moving the mouse too fast. When this would happen, I was unable to stop the camera from spinning with my mouse, and had to wait for it to slow down and stop. This could also be due to not having a proper camera controller script. I will need to revisit this and create a proper camera controller script. The second problem I was having was that over time, the character would rotate inside of controller, offsetting it's rotation from the camera in 3D space, which is also very problematic. Lastly, as we saw before, when "Apply Root Motion" was unchecked, I was getting problems with the sprinting animations looking dorky, possibly because they aren't blending properly.


In order to be able to check apply root motion, I had to do a few things, including deleting and re-importing most of my animations, with only the root translation zeroed out, will explain this later.

There is another reason why I spent a lot of time re-organizing my project. I have a lot of animations sitting on my computer, things I have purchased from places like the Unity Asset Store or Humble Bundle in the past, been drawing from many of those instead of just my MoCap. In order to go completely from MoCap, I would have to shoot a lot more MoCap, effective time management. My project had all of my animation libraries imported into it because I wanted to be able to preview them all. There were way too many animations, slowing things down, project is too big, can't move it from home to school computers. So, I separated them into 2 projects, one for previewing my animation libraries, the other for bringing chosen animations in and building functionality.

My animation preview layout:


There were way too many animations to just be sitting around in one Unity project unused:


I also worked on importing .fbx animations successfully from Blender. I found this video very helpful, from 7:35:

https://www.google.com/search?q=how+to+export+blender+animations+to+unity&rlz=1C1CHZL_enUS798US798&oq=how+to+export+blender+animations+&aqs=chrome.1.69i57j0l2.12989j0j7&sourceid=chrome&ie=UTF-8#kpvalbx=1

First thing to do is make sure all bones are selected in Pose Mode, not just the root bone or the armature object:



Next, these boxes need to be checked when exporting, all except "Force Start/End Keying."




For some reason, Blender doesn't like MoCap rigs or Vicon FBX format or something. Other rigs work, but when I try to export Vicon Blade MoCap animations/rigs from Blender to Unity, it breaks. I will need need to Use Motion Builder for those.

After that, when I have re-imported into Unity these check boxes need to be checked (all except Loop Time and Loop Pose):


The reason why these 3 check boxes need to be checked is to avoid the root rotation being applied to the character, which was causing him to rotate around in 3D space in the Unity engine.

So, sorta taken 2 steps forward, 1 step back, but it is for the better.
The reason why I deleted all of the animations from my project, zeroed out the root transforms, is so that I can check apply root motion, which fixes the problems I was having with blending between the running cycles, and also allows me to apply the root motion for some certain animations which will not be completely zeroed out on a single axis moving forward. This helps add the impression of motion to moving character so that it doesn't look like it's rolling in place while being translated on it's z axis. This is also good for me to know in case I need to use apply root motion in the future.

I also got jumping to work, but there are no animations applied, yet.


So the current state of my project is that I am still zeroing out root translation of the characters to the world origin. Once that is complete, they will be easy to add in because everything (state machines, animator, scripts, etc.) is still there.

Next week I will work more on fleshing out my character controller, adding more functionality. including falling and landing.

Saturday, March 2, 2019

Jump Code Tutorials

Unity Jump(more advanced):
This one was good, but a bit too complicated, and would only work if the object with my animaton controller script was a child of the object with my movement controller script, which is not ideal.
https://www.youtube.com/watch?v=vdOFUFMiPDU

Unity Jump:
I found this simple method of jumping to be more effective for my current needs.
https://www.youtube.com/watch?v=oikSPEfIk-Q

Jump friction sliding down wall:
https://www.youtube.com/watch?v=lj5VngpUB_4

Better Jumping:
https://www.youtube.com/watch?v=7KiK0Aqtmzc

All Updated State Machines and Blend Trees

These are all of the State Machines and Blend Trees that I set up for my character in Mecanim: