Thursday, 31 July 2014

Animator View

To do this,first click the Window tab and then select animation



Like any other view,it is resizeable,movable and rotatable,the add curve button can be expanded to view more options


To add Curve,click the + sign you wish to add a curve. Since we want the camera to fly around the scene,we would want a add position and rotation



The timeline is where we can established the timing of our animation. it is measured in frames and seconds. The red scrubber allows us to choose which to modify

To edit, simply click on the frame which we want to modify, and then move the camera position to where we want it
You will then notice there is a key frame that is added into the timeline with the appropriate values







Wednesday, 30 July 2014

Animator Scripting\



Unity’s Animation System allows you to create beautifully animated skinned characters. The Animation System supports animation blending, mixing, additive animations, walk cycle time synchronization, animation layers, control over all aspects of the animation playback (time, speed, blend-weights), mesh skinning with 1, 2 or 4 bones per vertex as well as supporting physically based rag-dolls and procedural animation. To obtain the best results, it is recommended that you read about the best practices and techniques for creating a rigged character with optimal performance in Unity on the Modeling Optimized Characters page.
Making an animated character involves two things; moving it through the world and animating it accordingly. If you want to learn more about moving characters around, take a look at the Character Controller page. This page focuses on the animation. The actual animating of characters is done through Unity’s scripting interface.

Avatar Mask



Specific body parts can be selectively enabled or disabled in an animation using a so-called Body Mask. Body masks are used in the Animation tab of the mesh import inspector and Animation Layers. Body masks enable you to tailor an animation to fit the specific requirements of your character more closely. For example, you may have a standard walking animation that includes both arm and leg motion, but if a character is carrying a large object with both hands then you wouldn’t want his arms to swing by his sides as he walks. However, you could still use the standard walking animation by switching off the arm movements in the body mask.
The body parts included are: Head, Left Arm, Right Arm, Left Hand, Right Hand, Left Leg, Right Leg and Root (which is denoted by the “shadow” under the feet). In the body mask, you can also toggle inverse kinematics (IK) for hands and feet, which will determine whether or not IK curves will be included in animation blending.
Click the avatar section to toggle inclusion or exclusion (green/red)
Double click in empty space surrounding the avatar to toggle all


Body mask in the Body Mask inspector (arms excluded)
In the Animation tab of the mesh import inspector, you will see a list entitled Clips that contains all the object’s animation clips. When you select an item from this list, options for the clip will be shown, including the body mask editor.
You can also create Body Mask Assets (Assets->Create->Avatar Body Mask), which show up as .mask files on disk.
The BodyMask assets can be reused in Animator Controllers, when specifying Animation Layers
A benefit of using body masks is that they tend to reduce memory overheads since body parts that are not active do not need their associated animation curves. Also, the unused curves need not be calculated during playback which will tend to reduce the CPU overhead of the animation.

Animation Layers
Unity uses Animation Layers for managing complex state machines for different body parts. An example of this is if you have a lower-body layer for walking-jumping, and an upper-body layer for throwing objects / shooting.
You can manage animation layers from the Layers Widget in the top-left corner of the Animator Controller.

You can add a new layer by pressing the + on the widget. On each layer, you can specify the body mask (the part of the body on which the animation would be applied), and the Blending type. Override means information from other layers will be ignored, while Additive means that the animation will be added on top of previous layers.
The Mask property is there to specify the body mask used on this layer. For example if you want to use upper body throwing animations, while having your character walk or run, you would use an upper body mask, like this






Animation-Curves and Events
"I DON'T HAVE CURVE IN MY UNITY,BUT I WILL TRY TO EXPLAIN IT HERE"

Animation curves can be attached to animation clips in the Animations tab of the Animation Import Settings.

The curve’s X-axis represents normalized time and always ranges between 0.0 and 1.0 (corresponding to the beginning and the end of the animation clip respectively, regardless of its duration).


Double-clicking an animation curve will bring up the standard Unity curve editor (see Editing Value Properties for further details) which you can use to add keys to the curve. Keys are points along the curve’s timeline where it has a value explicitly set by the animator rather than just using an interpolated value. Keys are very useful for marking important points along the timeline of the animation. For example, with a walking animation, you might use keys to mark the points where the left foot is on the ground, then both feet on the ground, right foot on the ground, etc. Once the keys are set up, you can move conveniently between key frames by pressing the Previous/Next Key Frame buttons. This will move the vertical red line and show the normalized time at the keyframe; the value you enter in the text box will then set the value of the curve at that time.

If you have a curve with the same name as one of the parameters in the Animator Controller, then that parameter will take its value from the value of the curve at each point in the timeline. For example, if you make a call to GetFloat from a script, the returned value will be equal to the value of the curve at the time the call is made. Note that at any given point in time, there might be multiple animation clips attempting to set the same parameter from the same controller. In that case, the curve values from the multiple animation clips are blended. If an animation has no curve for a particular parameter then the blending will be done with the default value for that parameter.



Animation Events



The power of animation clips can be increased by using Animation Events, which allow you to call functions in the object’s script at specified points in the timeline.

The function called by an animation event can optionally take one parameter. The parameter can be a float, string, int, object reference or an AnimationEvent object. The AnimationEvent object has member variables that allow a float, string, integer and object reference to be passed into the function all at once, along with other information about the event that triggered the function call.


You can add an animation event to a clip at the current play head position by clicking the Event button or at any point in the animation by double-clicking the Event Line at the point where you want the event to be triggered. Once added, an event can be re positioned by dragging with the mouse. You can delete an event by selecting it and pressing Delete, or by right-clicking on it and selecting Delete Event from the contextual menu.

Animation Events are shown in the Event Line. Add a new Animation Event by double-clicking the Event Line or by using the Event button.
When you add an event, a dialog box will appear to prompt you for the name of the function and the value of the parameter you want to pass to it.

The Animation Event popup dialog lets you specify which function to call with which parameter value.
The events added to a clip are shown as markers in the event line. Holding the mouse over a marker will show a tooltip with the function name and parameter value.


Holding the mouse cursor over an Animation Event marker will show which function it calls as well as the parameter value.

Tuesday, 29 July 2014

Animation Properties 

Using the inspector comes in three parts , Model ,Rig and animation. Today we'll be looking at Animations.


The ”position”,”rotation” and ”scale” error will allow us to get the position if its with a smaller value.and the less compression that we will get.
The clips section will show you what animation you have in the model.
When one of this clips are selected, all of the option for that specific clip are available. 

Below the timeline is the loop pose.




If the loop pose is checked,unity will try and mesh the start and the end to make it look smoother.The cycle offset is for mirroring animimation.If the bake into pose is checked, the avatar will not rotate with any turning within the animation.Used this if the animation is running in a straight line so that any deviationfrom a straight line is not affected,the root transform rotation can either be based on the body orientation at the start of the animation or the original source file of the animation.As with root trasformation,if checked in the bake into pose,the avatar will not move up or down in the animation. There is a few that it can be based on. Original takes from the original file.Otherwise it can be based on the avatar's center of mass or its feet. 





Humanoid Avatars

For Humanoid Characters,Can be configured to your own specification.


There are 3 tabs in the inspector panel, Model, Rig and Animation.To configure the Avatar click the rig tab, and make sure that the animation type is under "Humanoid" and then there will be a tick on the configure button below,You can configure your model manually . 
There is a game object box where you can click and chose a certain part from the avatar's heir achy

The Configuration scene is empty except for the hierachy of the Avatar. The inspector now has two tabs, Mapping and Muscles.


The inspector shows which of the bones are required and which are optional - the optional ones can have their movements interpolated automatically. For Mecanim to produce a valid match, your skeleton needs to have at least the required bones in place. In order to improve your chances for finding a match to the Avatar, name your bones in a way that reflects the body parts they represent (names like “LeftArm”, “RightForearm” are suitable here).
If the model does NOT yield a valid match, you can manually follow a similar process to the one used internally by Mecanim:-
  1. Sample Bind-pose (try to get the model closer to the pose with which it was modelled, a sensible initial pose)
  2. Automap (create a bone-mapping from an initial pose)
  3. Enforce T-pose (force the model closer to T-pose, which is the default pose used by Mecanim animations)


If the auto-mapping (Mapping->Automap) fails completely or partially, you can assign bones by either dragging them from the Scene or from the Hierarchy. If Mecanim thinks a bone fits, it will show up as green in the Avatar Inspector, otherwise it shows up in red.
Finally, if the bone assignment is correct, but the character is not in the correct pose, you will see the message “Character not in T-Pose”. You can try to fix that with Enforce T-Pose or rotate the remaining bones into T-pose

Muscle Setup
Mecanim allows you to control the range of motion of different bones using Muscles.
Once the Avatar has been properly configured, Mecanim will “understand” the bone structure and allow you to start working in the Muscles tab of the Avatar Inspector. Here, it is very easy to tweak the character’s range of motion and ensure the character deforms in a convincing way, free from visual artifacts or self-overlaps.

Blend Trees

Sometimes when animating you want to mix two or more animations

This creates a state where the blend tree is its motion instead of a single animation.


Double Clicking on the state, allows you to edit the blend tree

For now we will concentrate on 1D blend trees. Or in other words,one dimensional.

To start working with a new Blend Tree, you need to:
  1. Right-click on empty space on the Animator Controller Window.
  2. Select Create State > From New Blend Tree from the context menu that appears.
  3. Double-click on the Blend Tree to enter the Blend Tree Graph.

The settings will be read-only if the animation is imported from a model. If the node is a Blend Node, the Inspector for Blend Nodes will be shown.
You can select any of the nodes in the Blend Tree graph to inspect it in the Inspector.

When in two dimensional editing, there will be a directional button to show where your animation is in the scene, and there is also two axis, Axis Y and Axis X since its 2D. We can choose a animator parameter to represent the both Axis. For example we can choose  Velocity X and Velocity Y. Compare to 1D this choice is more open.Once you've chose your parameters,the next step is to attach motion. like 1D this could either be blend trees or motion Fields however not like 1D blend trees,the order which they are placed doesn't matter.
 Best used when your motions represent different directions, such as “walk forward”, “walk backward”, “walk left”, and “walk right”, or “aim up”, “aim down”, “aim left”, and “aim right”. Optionally a single motion at position (0, 0) can be included, such as “idle” or “aim straight”. In the Simple Directional type there should not be multiple motions in the same direction, such as “walk forward” and “run forward”.
This is how it would look like,the red dot will show the direction of the avatar,according to the animation transition.


Monday, 28 July 2014

Animator Controller

The Animator Controller is the main component by which animation behaviour is added to an object. This section describes the component in detail.




You can view and set up character behavior from the Animator Controller view (Menu: Window > Animator Controller).
or
You can just (Right Click > Create > Animator Controller)




This is what you would probably get. Then you just adjust the animation according to your animation liking

Note that the Animator Controller Window will always display the state machine from the most recently selected .controller asset, regardless of what scene is currently loaded.

Animator Parameter
Animation Parameters are variables that are defined within the animation system but can also be accessed and assigned values from scripts

  • Vector - a point in space
  • Int - an integer (whole number)
  • Float - a number with a fractional part
  • Bool - true or false value

Blend trees can also be used,it will be in my next post.


ANIMATION STATE

Animation States are the basic building blocks of an Animation State Machine. Each state contains an individual animation sequence (or blend tree) which will play while the character is in that state. When an event in the game triggers a state transition, the character will be left in a new state whose animation sequence will then take over.
When you select a state in the Animator Controller, you will see the properties for that state in the inspector,



SpeedThe default speed of the animation
MotionThe animation clip assigned to this state
Foot IKShould Foot IK be respected for this state
TransitionsThe list of transitions originating from this state

A new state can be added by right-clicking on an empty space in the Animator Controller Window and selecting Create State->Empty from the context menu. Alternatively, you can drag an animation into the Animator Controller Window to create a state containing that animation. (Note that you can only drag Mecanim animations into the Controller - non-Mecanim animations will be rejected.) States can also contain Blend Trees.(It will be shown in the next posting)

As shown in the Screen Shot below.




Thursday, 17 July 2014

Animator Component: It may differ to what you plan on animating.

For Example a 3D humanoid character will have a different animation than a 2D Character.

Animator controller
The Picture with a model attached, With the model there is an animator controller present. The first component in the Animator controller stores a reference to an Animator Controller asset.
Animator Controllers are used to determine which animation is being played in the scene.
For example you can tell you animator controller to program your model, to when it is suppose to be standing running or jumping. It will then play and blend the animation automatically


Avatar
An avatar is the asset that unity creates when importing a 3d humanoid.It contains a definition of the skeletal rig that the model has. Try to think as the avatar is the glue thats joins the model to the animation that binds it to the animator.
NOTE: For models with no skeletal rigging, an avatar is not required.





Apply Root Motion
The Root Transform is a projection on the Y plane of the Body Transform and is computed at runtime. At every frame, a change in the Root Transform is computed. This change in transform is then applied to the Game Object to make it move.



The Animation can be looped using the Root Transform or Using the Script that can be applied to the avatar.
This script is created with a function, (underline in red) and then it is attached to your game object.


Animate Physics



When turned on, animations will be executed in the physics loop. This is only useful in conjunction with kinematic rigid bodies.
An animated platform can apply velocity and friction to rigid bodies sitting on top of it. In order to use this, animate Physics must be enabled and animated object must be a kinematic rigid body.
IMPORTANT : AVATAR MUST HAVE A RIGID BODY

Culling Type

When culling is enabled, Unity might stop animating if it thinks that the results of the animation won't be visible to the user. This could save you some performance if you have things animating outside of the view port, whose animation is only important when the user can actually see the thing that is being animated. When Animation component is culled it won't do anything: it won't update animation states, execute events or sample animations.



Always Animate- 
Animation culling is disabled - object is animated even when off screen
Based On Renderers- Animation is disabled when renderers are not visible.

Based On Clip Bounds-Animation is disabled when Animation. local Bounds are not visible.
Based On User Bounds-Animation is disabled when Animation .local Bounds are not visible.


Thursday, 10 July 2014

Class Exercise - Terrain

Terrain


The First Terrain : Prehistoric View of the World.






Second Terrain : Sort of a Horror Eerie Look to it.

Third Terrain : Old Japanese Backyard.
Fourth Terrain : Dessert looking dunes and buildings.

Welcome to the unity 3D tutorial.

This blog site is for the use of class assignments but also helpful if your planning to do some modelling in unity 3D. Thanks for dropping by and viewing my blog. =) Feel Free to leave your comments.