CAGD Record Batch1
CAGD Record Batch1
Lab Record
III / IV B. Tech.
Computer Animation & Game Design Lab
(20CSLJO03)
Bapatla Engineering College::Bapatla(Autonomous)
Department of Computer Science and Engineering
CERTIFICATE
Redg. No.-
Experiment 1
1. Build a spaceship with polygons in maya?
Steps:
1.1 Starting the ship
This spaceship will be built starting with a simple polygonal cube .The Poly Faces will then be extruded
to create a more complex shape.
1 Place and position a primitive cube
Select Create->Polygon Primitives->Cube
2 Turn on backface culling
The Poly Faces that are facing away from the view are not displayed and cannot be selected
3 Select the two side faces of cube
Press the Shift key and Select the opposite facet handle
4 Extrude and scale Poly Faces
Select Polygons->Extrude
5 Add wing base
Press the g key to reactivate the Extrude tool and start a new extrusion
6 Extrude and shape wing
Press the g key. Click-drag on the blue Move handle. Click-drag on red Scale handle.
7 Add a top wing
Select the facet handle belonging to the top surface of the shape. Press the g key. Click-drag on red
Scale handle to create a long thin polygon centered in the top facet.
1.2 Air intake ports
In addition to extruding out, you can use the extrusion tool to push a polygonal facet into a surface to
create an opening. For the ship’s air intake ports, this technique will be used.
1 Create the front of the ports
Select the facet handle belonging to the side thruster port. Press the Shift key and Select the opposite
facet. Press the g key to re-evoke the Extrude tool and start a new extrusion.
2 Add a lip to the ports
To give the thruster a little bit of an edge, you will next create a little lip using the extrude tool.Press the
g key.
3 Extrude the hole
Press the g key.
Click-drag on blue Move handle to push this facet back deep into the spaceship
4 Add the rear thruster
Tumble the view around to see the back of the ship.Select the facet handle belonging to back facet of
the ship. Press the g key.
Repeat the steps used to create the front thruster ports to finish the back exhaust hole
1.3 The front cockpit
You can now continue to use the extrude tool to pull out a cockpit area for the spaceship.
1 Pick the front facet
Tumble around to see the front of the ship.
Select the facet handle belonging to front facet of the ship.
2 Extrude the front facet twice
Press the g key.
Click-drag on blue Move handle to pull this facet out.
Press the g key.
Page | 5
Lab Record Computer Animation & Game Design Lab
(20CSLJO03)
Use blue Move handle to pull a second facet out.
3 Scale and rotate the facet
Use the green Scale handle to scale the front facet down.
Use the red Scale handle to scale this facet in.
Use the green Move handle to move this piece down
1.4 Creating a more organic look
1 Smooth the spaceship
Press F8 to go back to Select by Object Type mode
Select Edit Polygons -> Smooth.
2 Edit the extrude history
In the Channel box, Select the polyExtrudeFacet1 node.
Select the Show Manipulator Tool.The manipulator for the first extrusion is displayed.
Use the blue Move handle to move the extrude in towards the center.
Both the extrude history and smooth action update, as the exhaust ports become more narrow
3 Edit the smooth history
Select the polySmoothFacet1 input node in the Channel box.
Set Divisions to 2.
4 Add a lattice
Change to the Animation menu set.
Select Deform -> Create Lattice.
In the Channel box, set the following under the ffd1LatticeShape node:
S Divisions to 4;
T Divisions to 2;
U Divisions to 6.
5 Edit the lattice points
Press F8 to go into Select by Component Type mode
Turn on the Points selection mask.The Poly Faces selection mask should turned off.
In the Top view, use the Shift key and click-drag to Select the twelve control points near the tips of the
wings
6 Move the tail
In the Perspective view, Select the six control points closest to the tail.
7 Move the lower back edge down
In the Side view, Select the four control points at the back lower edge.
Move these points down.
8 Move the wings tips down
In the Front view, Select all the control points on the right and left sides of the lattice.
Move these points down
9 Curve the nose forward and down
In the Side view, Select the front two rows of control points.
Move these points forward and down.
1.5 Finishing the model
1 Delete history
Press F8 to go back to Select by Object Type mode.
Select the spaceship.
Select Edit ->Delete by Type ->History.
2 Rename the polymesh
Rename the polymesh polyShip.
Page | 6
Lab Record Computer Animation & Game Design Lab
(20CSLJO03)
3 Save the file
Select File -> Save Scene As...
Save the file as polyShip.
OUTPUT:
Page | 7
Lab Record Computer Animation & Game Design Lab
(20CSLJO03)
Experiment 2
2. Build a Rocket with NURBS surfaces in maya?
Steps:
Page | 9
Lab Record Computer Animation & Game Design Lab
(20CSLJO03)
Experiment 3
3. Application of texture to the spaceship?
Steps:
3.1 Starting the ship
This spaceship will be built starting with a simple polygonal cube .The Poly Faces will then be extruded
to create a more complex shape.
1 Place and position a primitive cube
Select Create->Polygon Primitives->Cube
2 Turn on backface culling
The Poly Faces that are facing away from the view are not displayed and cannot be selected
3 Select the two side faces of cube
Press the Shift key and Select the opposite facet handle
4 Extrude and scale Poly Faces
Select Polygons->Extrude
5 Add wing base
Press the g key to reactivate the Extrude tool and start a new extrusion
6 Extrude and shape wing
Press the g key. Click-drag on the blue Move handle. Click-drag on red Scale handle.
8 Add a top wing
Select the facet handle belonging to the top surface of the shape. Press the g key. Click-drag on red
Scale handle to create a long thin polygon centered in the top facet.
3.2 Air intake ports
In addition to extruding out, you can use the extrusion tool to push a polygonal facet into a surface to
create an opening. For the ship’s air intake ports, this technique will be used.
2 Create the front of the ports
Select the facet handle belonging to the side thruster port. Press the Shift key and Select the opposite
facet. Press the g key to re-evoke the Extrude tool and start a new extrusion.
2 Add a lip to the ports
To give the thruster a little bit of an edge, you will next create a little lip using the extrude tool.Press the
g key.
3 Extrude the hole
Press the g key.
Click-drag on blue Move handle to push this facet back deep into the spaceship
4 Add the rear thruster
Tumble the view around to see the back of the ship.Select the facet handle belonging to back facet of
the ship. Press the g key.
Repeat the steps used to create the front thruster ports to finish the back exhaust hole
3.3 The front cockpit
You can now continue to use the extrude tool to pull out a cockpit area for the spaceship.
1 Pick the front facet
Tumble around to see the front of the ship.
Select the facet handle belonging to front facet of the ship.
2 Extrude the front facet twice
Press the g key.
Click-drag on blue Move handle to pull this facet out.
Press the g key.
Page | 10
Lab Record Computer Animation & Game Design Lab
(20CSLJO03)
Use blue Move handle to pull a second facet out.
3 Scale and rotate the facet
Use the green Scale handle to scale the front facet down.
Use the red Scale handle to scale this facet in.
Use the green Move handle to move this piece down
3.4 Creating a more organic look
1 Smooth the spaceship
Press F8 to go back to Select by Object Type mode
Select Edit Polygons -> Smooth.
2 Edit the extrude history
In the Channel box, Select the polyExtrudeFacet1 node.
Select the Show Manipulator Tool.The manipulator for the first extrusion is displayed.
Use the blue Move handle to move the extrude in towards the center.
Both the extrude history and smooth action update, as the exhaust ports become more narrow
3 Edit the smooth history
Select the polySmoothFacet1 input node in the Channel box.
Set Divisions to 2.
4 Add a lattice
Change to the Animation menu set.
Select Deform -> Create Lattice.
In the Channel box, set the following under the ffd1LatticeShape node:
S Divisions to 4;
T Divisions to 2;
U Divisions to 6.
5 Edit the lattice points
Press F8 to go into Select by Component Type mode
Turn on the Points selection mask.The Poly Faces selection mask should turned off.
In the Top view, use the Shift key and click-drag to Select the twelve control points near the tips of the
wings
6 Move the tail
In the Perspective view, Select the six control points closest to the tail.
7 Move the lower back edge down
In the Side view, Select the four control points at the back lower edge.
Move these points down.
8 Move the wings tips down
In the Front view, Select all the control points on the right and left sides of the lattice.
Move these points down
9 Curve the nose forward and down
In the Side view, Select the front two rows of control points.
Move these points forward and down.
3.5 Finishing the model
1 Delete history
Press F8 to go back to Select by Object Type mode.
Select the spaceship.
Select Edit ->Delete by Type ->History.
2 Rename the polymesh
Rename the polymesh polyShip.
Page | 11
Lab Record Computer Animation & Game Design Lab
(20CSLJO03)
3 Save the file
Select File -> Save Scene As...
Save the file as polyShip.
3.6 Texturing the Ship
1 Create and assign a new shading group
• Open the Hypershade window.
• Create a Blinn Material node.
• Assign the Blinn Material to the polymesh object.
• Rename the material node polyShipBlinn.
• Rename the blinn1SG node to polyShipSG.
2 Turn on hardware texturing
• Turn on hardware texturing in each view panel
The display of the model does not change because there are no textures assigned
3 Map an image file to the color
• Open the attributes for the polyShipBlinn node.
• Map the Color attribute with a 2D File texture node.
• Rename the file1 node polyColor.
• Click on the Folder Icon button next to Image Name.
• In the sourceimages directory of the projectTwo project, locate the polyColor.sgi image file.
• Click See Image.
Output:
Page | 12
Lab Record Computer Animation & Game Design Lab
(20CSLJO03)
Experiment 4
4. Export a 3D model from maya (.fbx file)?
Steps:-
1. Launch Maya.
2. Select File > Export All, or File > Export Selection. The Export All, or Export Selection
dialog box appears.
3. Select FBX from File of Type menu
4. Enter a name for the FBX file you want to export.
5. The FBX Export options appear at the right of the Maya Export dialog box.
6. Set the export options you want to use or select a preset from the Presets menu
7. If file contains textures and maps, it is important to activate the Embed Media option
8. Click Export in the Maya Export dialog box
Output:
Page | 13
Lab Record Computer Animation & Game Design Lab
(20CSLJO03)
Experiment 5
5. Export a model from Z-Brush to maya?
Steps:
If you need to bring a model from ZBrush back into Maya for further editing or
rendering, it is done as an .obj.
1. In ZBrush select Tool Export.
2. Open Maya and select File Import . Set Create Multiple objects to False. This
is very important. If the vertex order of the object changes in any way, the
models will not work correctly when moving between the two programs.
Output:
Page | 14
Lab Record Computer Animation & Game Design Lab
(20CSLJO03)
Experiment 6
6. Create a sprite sheet and its animation in unity?
Steps:
1. Download assets (fire_fx_v1.0.zip) from https://brullov.itch.io/fire-animation
2. First start by creating a 2D project in Unity
3. To start things off, simply drag and drop your sprite sheet into the Assets
4. Now that we have a spritesheet to work with, we need to tell Unity that it’s a spritesheet, or in other
words, an image containing multiple images. To do this we have to perform a couple of steps. Select
the newly installed sprite, then in the Inspector, follow the following steps:
a. Select Sprite Mode
b. Select ‘Multiple’
c. Click ‘Sprite Editor Button’
5. When prompted to apply import settings, click Apply
6. Now in the Sprite editor, select Slice then Type then Grid by Cell Count
7. In this case sprite sheet is composed of 1 rows with 6 columns in each. So enter the appropriate values
in Columns & Rows, then click the Slice button.
8. Now apply the slice
9. Now expand the newly created sprite set by clicking the play icon to the right.
10. Once expanded, select the frames of animation you want to include in your animation. You can hold
Ctrl when clicking to select multiple frames of animation. Once selected, drag and drop in the view.
11. You will now be prompted to create an animation. I called FIRE_ANIMATION, then click Save.
12. click on play
Outputs:
Page | 15
Lab Record Computer Animation & Game Design Lab
(20CSLJO03)
Experiment 7
7. Creation of basic transformation in unity using c script?
Steps:
1. using System.Collections;
2. using System.Collections.Generic;
3. using UnityEngine;
4.
5. public class move : MonoBehaviour {
6.
7. // Use this for initialization
8. void Start () {
9.
10. }
11.
12. // Update is called once per frame
13. void Update () {
14. transform.Translate (0.05f, 0f, 0f);
15.
16. }
17. }
7. Go back to the Unity window. Drag and drop the move script onto the sphere.
8. Click on the Play button. The sphere will move slowly in a forward direction.
Object moves backward
1. using System.Collections;
2. using System.Collections.Generic;
3. using UnityEngine;
4.
5. public class move : MonoBehaviour {
Page | 16
Lab Record Computer Animation & Game Design Lab
(20CSLJO03)
6.
7. // Use this for initialization
8. void Start () {
9.
10. }
11.
12. // Update is called once per frame
13. void Update () {
14. transform.Translate (-0.05f, 0f, 0f);
15.
16. }
17. }
1. using System.Collections;
2. using System.Collections.Generic;
3. using UnityEngine;
4.
5. public class move : MonoBehaviour {
6.
7. // Use this for initialization
8. void Start () {
9.
10. }
11.
12. // Update is called once per frame
13. void Update () {
14. transform.Translate (0.05f, 0.05f, 0f);
15.
16. }
17. }
10. Save the program. Go to Unity and click on the Play button. The sphere will move upward
Down
1. using System.Collections;
2. using System.Collections.Generic;
3. using UnityEngine;
4.
5. public class move : MonoBehaviour {
6.
7. // Use this for initialization
8. void Start () {
Page | 17
Lab Record Computer Animation & Game Design Lab
(20CSLJO03)
9.
10. }
11.
12. // Update is called once per frame
13. void Update () {
14. transform.Translate (0.05f, -0.05f, 0f);
15.
16. }
17. }
1. using System.Collections;
2. using System.Collections.Generic;
3. using UnityEngine;
4.
5. public class move : MonoBehaviour {
6.
7. // Use this for initialization
8. void Start () {
9.
10. }
11.
12. // Update is called once per frame
13. void Update () {
14. transform.Translate (0.00f, 0.00f, 0.05f);
15.
16. }
17. }
1. using System.Collections;
2. using System.Collections.Generic;
3. using UnityEngine;
4.
5. public class move : MonoBehaviour {
6.
7. // Use this for initialization
8. void Start () {
9.
10. }
11.
Page | 18
Lab Record Computer Animation & Game Design Lab
(20CSLJO03)
12. // Update is called once per frame
13. void Update () {
14. transform.Translate (0.001f, 0.01f, 0.01f);
15.
16. }
17. }
13. Save the program. Go to Unity and click on the Play button. The sphere will be moving slowly
to the right.
Move the object by keypress
1. using System.Collections;
2. using System.Collections.Generic;
3. using UnityEngine;
4.
5. public class move : MonoBehaviour {
6.
7. // Use this for initialization
8. void Start () {
9.
10. }
11.
12. // Update is called once per frame
13. void Update () {
14. if (Input.GetKey (KeyCode.W)) {
15. transform.Translate (0.05f, 0f, 0f);
16. }
17. if (Input.GetKey (KeyCode.S)) {
18. transform.Translate (-0.05f, 0f, 0f);
19. }
20. if (Input.GetKey (KeyCode.D)) {
21. transform.Translate (0.0f, 0f, -0.05f);
22. }
23. if (Input.GetKey (KeyCode.A)) {
24. transform.Translate (0.0f, 0f, 0.05f);
25. }
26. }
27.
28. }
Page | 19
Lab Record Computer Animation & Game Design Lab
(20CSLJO03)
17. Press the “D” key. The object will move into the Right side.
18. Press the “A” key. The object will move into the left side
Output:
Page | 20
Lab Record Computer Animation & Game Design Lab
(20CSLJO03)
Experiment 8
8. Building health bar and control values on it with c script?
Steps:
1. Create a new project.
2. In new scene, create an empty game object and call it Player.
3. Once created, select the Player game object and navigate to the Inspector window and reset the
transform component
4. Next, click on the Add component button and look for Sprite Renderer using the search bar.
5. Once Sprite Renderer is added, navigate to it and click on the little circle beside the Sprite
parameter. Then, look for Knob and select it
Adding Health Points:
6. Of course, before we can create the health bar we will need first to create the health points.
7. To start, we’re gonna need to create a new C# script and we’ll call it Health.cs.
1. using System.Collections;
2. using System.Collections.Generic;
3. using UnityEngine;
4. public class Health : MonoBehaviour
5. {
6. public int curHealth = 0;
7. public int maxHealth = 100;
8. public HealthBar healthBar;
9. void Start()
10. {
11. curHealth = maxHealth;
12. }
13. void Update()
14. {
15. if( Input.GetKeyDown( KeyCode.Space ) )
16. {
17. DamagePlayer(10);
18. }
Page | 21
Lab Record Computer Animation & Game Design Lab
(20CSLJO03)
19. }
20. public void DamagePlayer( int damage )
21. {
22. curHealth -= damage;
23. healthBar.SetHealth( curHealth );
24. }
25. }
8. what we’re doing is we’re creating a set of functions that initialize the value of the current health
of the player to the maximum. Then, we also have the function that gives damages to the player.
So, if you take a look at the Update function, as you can see we’re checking if the Player hits the
SPACE bar, if the player did, then the player will receive damage.
Creating the Health Bar:
9. Now that we have our player health points set up, let’s begin working on displaying the actual
health bar.
10. To start, navigate to your hierarchy, right-click and select UI then Image.
11. This will be creating a new canvas especially if there’s currently none in the scene. Inside the
canvas, there will also be an image UI object created.
12. With all that being said, select your Canvas game object and press F key to show the entire
canvas on the screen.
13. Next, select your Image game object and make sure that it is placed right at the center of the
canvas like below.
14. Next, we’ll be changing the graphic being used in this object so download the PNG image
provided below and import it to your project.
15. To import the downloaded file, just navigate to the file that you wish to import and then just
simply drag it into your project window like below.
16. Another way to import your files is by going to your assets folder which is located in your project
folder.
17. Once the image is imported, go back to your hierarchy, select the Image UI object and navigate
to its Image component and change its Source Image to the image that we have just imported.
The health bar.
18. Next, just below the Preserve Aspect check box, click the Set Native Size button.
19. This will resize the image based on the actual resolution of the image file.
20. Next, let’s rename our Image UI object to something like… Health Bar Border.
21. The next thing that we’re going to do is to create an empty game object inside the Canvas. So
right-click on the Canvas game object and select Create Empty
22. Let’s rename this Empty game object to Health Bar
Page | 22
Lab Record Computer Animation & Game Design Lab
(20CSLJO03)
23. Next, with the Health Bar game object selected press T. This will enable the Rect Tool.
24. Now, resize the Health Bar to the same size as the Health Bar Border.
25. Next, drag the Health Bar Border game object to the Health Bar game object to make it as its
child, like below.
26. Let’s create another Image, so with your Health Bar game object selected, right-click then
navigate to UI then select Image.
27. simply drag the Image object above the Health Bar Border game object like below
28. Now let’s change the color of this image since this object will represent the actual bar for the
player’s health point.
29. But before that, let’s rename first our Image game object to Health Bar Image because we don’t
want it to call as Image all the time.
30. Nice! Now let’s select our Health Bar Image and navigate to its Image component.
31. In the color property, change its hexadecimal value from #FFFFFF to #DB2525.
32. Now, we want our Health Bar Image to be the same size as its parent so to do that, go to its Rect
Transform component and click on the box with the red cross in it. This will show you the anchor
presets
33. With the anchor presets being showed, hold ALT key, and select the stretch preset at the bottom-
right corner of the preset’s window.
34. This will fill the entire Health Bar game object.
35. Select the Health Bar Border game object and navigate to its Rect Transform component and
click on the Anchor Preset button and select the preset at the bottom-right corner. Without
pressing the ALT key.
Using Slider UI for the Health Points:
36. Now the next thing that we’re going to do is to make the Health Bar an actual health bar where
the red fill can decrease or increase.
37. To do that, we’re going to use the Slider component.
38. So with your Health Bar selected, go to its inspector and click Add Component and look for
Slider
39. Next, we’re going to set the Slider component to the following values.
a. Interactable is unchecked
b. Transition is set to none
c. Navigation is set to none
d. Fill Rect, drag the Health Bar Image object to its value
40. By doing so, a new set of parameters will show up such as the direction of the slider, the
minimum and the maximum value, and the actual value.
41. By sliding the value you will see that the Health Bar Image also gets affected.
Page | 23
Lab Record Computer Animation & Game Design Lab
(20CSLJO03)
Scripting the Health Bar:
42. So with your Health Bar game object selected, click the Add Component and look for New
Script. Select that and set the name of the script to HealthBar.
43. Once the script is created, open it with visual studio and copy the following code.
1. using System.Collections;
2. using System.Collections.Generic;
3. using UnityEngine;
4. using UnityEngine.UI;
5. public class HealthBar : MonoBehaviour
6. {
7. public Slider healthBar;
8. public Health playerHealth;
9. private void Start()
10. {
11. playerHealth = GameObject.FindGameObjectWithTag("Player").GetComponent<Health>();
12. healthBar = GetComponent<Slider>();
13. healthBar.maxValue = playerHealth.maxHealth;
14. healthBar.value = playerHealth.maxHealth;
15. }
16. public void SetHealth(int hp)
17. {
18. healthBar.value = hp;
19. }
20. }
Using the Script:
44. Once all your scripts are saved, navigate back to your hierarchy and select your Player game
object.
45. Then, drag the Health.cs script to its inspector to assign the script.
46. Go to its inspector and drag the Health Bar game object to the Health Bar parameter of the health
script like below.
47. Still with your Player selected, navigate to the Tag dropdown and select Player.
48. Save your scene and test your game.
49. Your player’s health should decrease whenever you hit your spacebar.
Page | 24
Lab Record Computer Animation & Game Design Lab
(20CSLJO03)
Output:
Page | 25
Lab Record Computer Animation & Game Design Lab
(20CSLJO03)
Experiment 9
9. Experiment with canvas object- creation of text box, buttons and control them with
c script?
Steps:
1. Create new project in unity
2. To add text to your game, Go to GameObject->UI->Text-TextMeshPro
3. To change things at run time,need to write code to update the text while we are playing
TextUpdater Script.cs:
This script updates text value to match the number of seconds our game has been playing
using TMPro;
using UnityEngine;
void OnEnable(){
TimeText.SetText(Time.time.ToString());
}
}
4. Lets add a button to refresh that time whenever it’s clicked
Add a Button:
5. Goto GameObject ->UI->Button-TextMeshPro
6. Set Height and width to 300
7. Expand the button and select the Text TextMeshPro and make it Refresh
8. Button is clickable but it wont actually do anything
9. Scroll down to Button component,expand it,see an OnClick() Section,hit the +
button,drag the player text object here and click on the function objects .This shows all of
the components on that object including TextUpdater and all of the public methods on
Page | 26
Lab Record Computer Animation & Game Design Lab
(20CSLJO03)
there now on enable method isn’t public
10. We don’t call an enable method from button,instead refactor the above code by moving
the time text code into a public method named RefreshTimeText as shown below:
using TMPro;
using UnityEngine;
void OnEnable()=>RefreshTimeText();
public void RefreshTimeText(){
TimeText.SetText(Time.time.ToString());
}
}
11. calling RefreshTimeText on enable and add that as an onclick listener so choose
dropdown choose TextUpdater and can find RefreshTimeText
12. Press Play
Output:
Page | 27
Lab Record Computer Animation & Game Design Lab
(20CSLJO03)
Experiment 10
10. Experiment with onCollisionEnter2D() and onCollisionExit2D() methods in
unity?
Steps:
2. using System.Collections.Generic;
Page | 28
Lab Record Computer Animation & Game Design Lab
(20CSLJO03)
3. using UnityEngine;
4.
6. {
9. {
10.
11. }
12.
16.
17. }
20. Destroy(col.gameObject);
21. }
24.
25. }
28. }
29.
30. }
Page | 29
Lab Record Computer Animation & Game Design Lab
(20CSLJO03)
Output:
Page | 30
Lab Record Computer Animation & Game Design Lab
(20CSLJO03)
Experiment 11
11. Controlling transitions in animator based on boolean and float variables?
Steps:
Page | 31
Lab Record Computer Animation & Game Design Lab
(20CSLJO03)
17. Add Condition: Click on the transition arrow idle->run, go to the Inspector, and add a
condition ‘run=true’ using the idle parameter to control the switch
18. Select character in Hierarchy and click on add component ,create new script with the
following code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
Animator animator;
// Start is called before the first frame update
void Start()
{
animator=GetComponent<Animator>();
animator.SetBool("idle", true);
animator.SetBool("walk", false);
animator.SetBool("run", false);
animator.SetFloat("speed",1.0f);
Page | 32
Lab Record Computer Animation & Game Design Lab
(20CSLJO03)
return;
}
else {
animator.SetBool("run", false);
animator.SetBool("walk", false);
animator.SetBool("idle", true);
animator.SetFloat("speed", 0.0f);
}
}
}
Outputs:
Page | 33
Lab Record Computer Animation & Game Design Lab
(20CSLJO03)
Page | 34
Experiment 12
12. Implement camera following in unity with c script?
Steps:
1. Create Unity Project and select layout as 2 by 3.
2. Import Soccer ball from asset store in Unity
3. Select Soccer ball and click on Add Component in Inspection tab and select new script and
rename it as move and add the following code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
Page | 35
transform.Translate (0.0f, 0f, -0.05f);
}
if (Input.GetKey (KeyCode.A)) {
transform.Translate (0.0f, 0f, 0.05f);
}
}
}
4. Select Main Camera,click on Add Component in Inspection tab and create new script and rename
it as CameraFollow.cs and select target as Soccer ball.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
Page | 36
private void FixedUpdate(){
transform.position=target.position-offset;
}
}
5. Run Play , Select Game tab and move the Soccer ball by pressing W,A,S,D Keys ,observe that
camera also moves along with the Soccer ball in Scene
Output:
Page | 37
Experiment 13
13. Creation of animated materials in unity?
Steps:
3. In the Project Window,Right Click and Create Material and Check the Emission in
Inspector tab and Select a color
4. Add Animation tab in Project tab by right clicking and selecting Animation in add tab
5. Select the Cube and Click on Create in the Animation tab and save as New Animation in
Assets->Scene Folder.
6. Add the property to the animation by selecting Mesh Render->Material.Emission.color
8. click on AddKeyFrame ,press on Record Button to start ,select new color from the New
Material Emission color and again press on Record Button to stop
9. Repeat Step8 for time frames 1:00,1:30,2:00,2:30 and 3:00
10. Run play and observe the animated cube projecting different colors
Output:
Experiment 14
14. Import 3D model into unity from maya?
Steps:
1. Open Maya 2024
2. Choose one of the Scenes(selecting Spaceship)
3. Select the Object
4. File->Export Selection->Select File types as FBX Export->click on Export Selection-
>Give file Name and save
5. Create New 3D Project in Unity
6. Right Click in Assets and Select Import New Assets
7. Give the path of the file saved in Step4
8. Drag the spaceship from assets to Hierarchy or Game tab
9. Click on Spaceship in Hierarchy tab
Output:
Experiment 15
15. Creation of 3D game in unity with multiple states?
Steps:
1. Download survival shooter game zip file from
https://github.com/EvanderChristianDumalang/Survival-Shooter
Output: