SlideShare a Scribd company logo
1 of 12
Summary
In this tutorial, you will see how components add functionality to GameObjects. The
component you will see in action here, the RigidBody Component, lets a GameObject
behave like a physical object instead of floating in space. In this tutorial, you will:
● Position the Main Camera to display action in the Game view.
● Explore the relationship between GameObjects and components.
● Identify specific components in the Inspector window.
● Add physical properties to a 3D GameObject by applying the RigidBody component
and setting its properties.
● Enter Play mode to preview a Scene in the Game view.
● Experiment with 3D physics in Unity.
1.Overview
Components add behaviors and functionality to a GameObject. You have
used the Transform Component — and that is just the beginning! In this
tutorial, you will add another component, the RigidBody Component, which
gives a GameObject physical properties so that it can interact with gravity
and other GameObjects. You will also position the Main Camera to watch
how a GameObject responds to gravity in 3D.
2.Before you begin
1. Create a new
Sphere
GameObject in the
Hierarchy.
2. Move the
sphere to the
space inside the
Monument, so
that it is
positioned in
“mid-air” above
the steps. You
can use the
Transform tools,
the Transform
Component in the
Inspector, or
both.
3.Position the Main Camera
In every new Scene, there is a camera like the one shown below.
This camera, named Main Camera in the
Hierarchy, captures and displays your
Scene to the player as it appears in the
Game view. While the Scene view is
where you build Scenes, the Game view
is a preview of the way your game
appears to the player.
The camera in your Scene is a
GameObject like any other. When you
select it, you will see its Transform
Component in the Inspector window. You
can change these settings as you would
with any other GameObject. Note that
scaling a camera will have no effect.
When you select a camera, you see the
outlines of a pyramid-like shape called
the frustum. The frustum shows you
what part of your Scene the camera is
viewing. Anything outside the frustum is
not visible to the camera.
When a camera is selected (1), you can expand the Camera Component in the
Inspector (2) to open a Camera Preview window (3) that shows you what is visible
to the camera in the Scene.
Move the camera to a position where it can “see” the ball and the steps below it.
Tip: You can also move the camera to align with your current scene view by selecting it in the Hierarchy window and then pressing
Ctrl+Shift+F.
Select the play button to run the game. Notice that nothing is happening at the moment. This is because you still need to apply a
component to the sphere to tell it how it needs to interact with the physics of the game. In this case, you need to make it solid so that
it reacts to gravity.
4.Make the sphere solid
Remember when you created a sphere that was inside a cube? Objects in the physical
world don’t exist inside other objects that way, but in a Unity Scene, by default,
GameObjects don’t have mass or respond to gravity. To make a GameObject behave
like a real-world physical object, you can give it physical properties by adding a
RigidBody Component.
To add the RigidBody Component to the Sphere GameObject:
1. In the Hierarchy window, select the Sphere.
2. Select the Add Component button in the Inspector window.
3. Use the search bar to find a Rigidbody component and select it. Note that there are two options available, Rigidbody and
Rigidbody 2D. Make sure you select the Rigidbody component, not the 2D one.
4. In the RigidBody Component in the Inspector, select Use Gravity if it is not already selected.
5. To see the effect of these properties, start the game by pressing the Play button, which will display the Game
view.
The ball falls and rolls down the steps. If it does not roll, try moving it to a new position using the transform tools and
run the game again.
Note: for Physics Best Practises see this Tutorial for more information.
5.Experiment with falling
GameObjects
Try variations of this exercise. Move the Sphere GameObject and the Main Camera to get the results you want. More things to try:
● Add more spheres with RigidBody Components at varying heights.
● Add other primitives and see how they behave.
● Drop objects in different places.
● Rotate the Monument GameObject.
One thing to note is that you can change the properties, values and position of a selected GameObject while the game is running,
but when the game is stopped all values will revert back to what they were before the game was started. This is useful to test
different parameters during runtime, but if you want the changes to be permanent, you need to make the changes while the game is
stopped.

More Related Content

Similar to Unity - Add components to 3D GameObjects

Fps tutorial 2
Fps tutorial 2Fps tutorial 2
Fps tutorial 2unityshare
 
UE4BlueprintLadderVolumeTutorial
UE4BlueprintLadderVolumeTutorialUE4BlueprintLadderVolumeTutorial
UE4BlueprintLadderVolumeTutorialJustin Plowman
 
Run and jump tutorial (part 3) behaviours
Run and jump tutorial (part 3)   behavioursRun and jump tutorial (part 3)   behaviours
Run and jump tutorial (part 3) behavioursMuhd Basheer
 
Flash cs4 tutorials_2009
Flash cs4 tutorials_2009Flash cs4 tutorials_2009
Flash cs4 tutorials_2009techbed
 
How tomakea gameinunity3d
How tomakea gameinunity3dHow tomakea gameinunity3d
How tomakea gameinunity3dDao Tung
 
Unity introduction for programmers
Unity introduction for programmersUnity introduction for programmers
Unity introduction for programmersNoam Gat
 
Tutorial2 scrolling shooter
Tutorial2 scrolling shooterTutorial2 scrolling shooter
Tutorial2 scrolling shooterhccit
 
Exercise 1.pptx
Exercise 1.pptxExercise 1.pptx
Exercise 1.pptxkostasan1
 
Unity Google VR Cardboard Deployment on iOS and Android
Unity Google VR Cardboard Deployment on iOS and AndroidUnity Google VR Cardboard Deployment on iOS and Android
Unity Google VR Cardboard Deployment on iOS and AndroidKobkrit Viriyayudhakorn
 
Introduction to Unity3D and Building your First Game
Introduction to Unity3D and Building your First GameIntroduction to Unity3D and Building your First Game
Introduction to Unity3D and Building your First GameSarah Sexton
 
Building your first game in Unity 3d by Sarah Sexton
Building your first game in Unity 3d  by Sarah SextonBuilding your first game in Unity 3d  by Sarah Sexton
Building your first game in Unity 3d by Sarah SextonBeMyApp
 

Similar to Unity - Add components to 3D GameObjects (20)

unity basics
unity basicsunity basics
unity basics
 
Fps tutorial 2
Fps tutorial 2Fps tutorial 2
Fps tutorial 2
 
UE4BlueprintLadderVolumeTutorial
UE4BlueprintLadderVolumeTutorialUE4BlueprintLadderVolumeTutorial
UE4BlueprintLadderVolumeTutorial
 
Run and jump tutorial (part 3) behaviours
Run and jump tutorial (part 3)   behavioursRun and jump tutorial (part 3)   behaviours
Run and jump tutorial (part 3) behaviours
 
03 unity 3_d_part_2
03 unity 3_d_part_203 unity 3_d_part_2
03 unity 3_d_part_2
 
Rolling The Dice
Rolling The DiceRolling The Dice
Rolling The Dice
 
Boob jiggle in Unity Part1
Boob jiggle in Unity Part1Boob jiggle in Unity Part1
Boob jiggle in Unity Part1
 
Flash cs4 tutorials_2009
Flash cs4 tutorials_2009Flash cs4 tutorials_2009
Flash cs4 tutorials_2009
 
How tomakea gameinunity3d
How tomakea gameinunity3dHow tomakea gameinunity3d
How tomakea gameinunity3d
 
Unity introduction for programmers
Unity introduction for programmersUnity introduction for programmers
Unity introduction for programmers
 
Lecture2_practice.pdf
Lecture2_practice.pdfLecture2_practice.pdf
Lecture2_practice.pdf
 
Tutorial2 scrolling shooter
Tutorial2 scrolling shooterTutorial2 scrolling shooter
Tutorial2 scrolling shooter
 
Read mepdf v3_0_02setupunit
Read mepdf v3_0_02setupunitRead mepdf v3_0_02setupunit
Read mepdf v3_0_02setupunit
 
Exercise 1.pptx
Exercise 1.pptxExercise 1.pptx
Exercise 1.pptx
 
Unity workshop
Unity workshopUnity workshop
Unity workshop
 
PICS QUIZ - INTEGRATION
PICS QUIZ - INTEGRATIONPICS QUIZ - INTEGRATION
PICS QUIZ - INTEGRATION
 
Maya
MayaMaya
Maya
 
Unity Google VR Cardboard Deployment on iOS and Android
Unity Google VR Cardboard Deployment on iOS and AndroidUnity Google VR Cardboard Deployment on iOS and Android
Unity Google VR Cardboard Deployment on iOS and Android
 
Introduction to Unity3D and Building your First Game
Introduction to Unity3D and Building your First GameIntroduction to Unity3D and Building your First Game
Introduction to Unity3D and Building your First Game
 
Building your first game in Unity 3d by Sarah Sexton
Building your first game in Unity 3d  by Sarah SextonBuilding your first game in Unity 3d  by Sarah Sexton
Building your first game in Unity 3d by Sarah Sexton
 

Recently uploaded

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 

Recently uploaded (20)

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 

Unity - Add components to 3D GameObjects

  • 1. Summary In this tutorial, you will see how components add functionality to GameObjects. The component you will see in action here, the RigidBody Component, lets a GameObject behave like a physical object instead of floating in space. In this tutorial, you will: ● Position the Main Camera to display action in the Game view. ● Explore the relationship between GameObjects and components. ● Identify specific components in the Inspector window. ● Add physical properties to a 3D GameObject by applying the RigidBody component and setting its properties. ● Enter Play mode to preview a Scene in the Game view. ● Experiment with 3D physics in Unity.
  • 2. 1.Overview Components add behaviors and functionality to a GameObject. You have used the Transform Component — and that is just the beginning! In this tutorial, you will add another component, the RigidBody Component, which gives a GameObject physical properties so that it can interact with gravity and other GameObjects. You will also position the Main Camera to watch how a GameObject responds to gravity in 3D.
  • 3. 2.Before you begin 1. Create a new Sphere GameObject in the Hierarchy.
  • 4. 2. Move the sphere to the space inside the Monument, so that it is positioned in “mid-air” above the steps. You can use the Transform tools, the Transform Component in the Inspector, or both.
  • 5. 3.Position the Main Camera In every new Scene, there is a camera like the one shown below.
  • 6. This camera, named Main Camera in the Hierarchy, captures and displays your Scene to the player as it appears in the Game view. While the Scene view is where you build Scenes, the Game view is a preview of the way your game appears to the player. The camera in your Scene is a GameObject like any other. When you select it, you will see its Transform Component in the Inspector window. You can change these settings as you would with any other GameObject. Note that scaling a camera will have no effect. When you select a camera, you see the outlines of a pyramid-like shape called the frustum. The frustum shows you what part of your Scene the camera is viewing. Anything outside the frustum is not visible to the camera.
  • 7. When a camera is selected (1), you can expand the Camera Component in the Inspector (2) to open a Camera Preview window (3) that shows you what is visible to the camera in the Scene.
  • 8. Move the camera to a position where it can “see” the ball and the steps below it. Tip: You can also move the camera to align with your current scene view by selecting it in the Hierarchy window and then pressing Ctrl+Shift+F. Select the play button to run the game. Notice that nothing is happening at the moment. This is because you still need to apply a component to the sphere to tell it how it needs to interact with the physics of the game. In this case, you need to make it solid so that it reacts to gravity.
  • 9. 4.Make the sphere solid Remember when you created a sphere that was inside a cube? Objects in the physical world don’t exist inside other objects that way, but in a Unity Scene, by default, GameObjects don’t have mass or respond to gravity. To make a GameObject behave like a real-world physical object, you can give it physical properties by adding a RigidBody Component. To add the RigidBody Component to the Sphere GameObject: 1. In the Hierarchy window, select the Sphere. 2. Select the Add Component button in the Inspector window.
  • 10. 3. Use the search bar to find a Rigidbody component and select it. Note that there are two options available, Rigidbody and Rigidbody 2D. Make sure you select the Rigidbody component, not the 2D one.
  • 11. 4. In the RigidBody Component in the Inspector, select Use Gravity if it is not already selected. 5. To see the effect of these properties, start the game by pressing the Play button, which will display the Game view. The ball falls and rolls down the steps. If it does not roll, try moving it to a new position using the transform tools and run the game again. Note: for Physics Best Practises see this Tutorial for more information.
  • 12. 5.Experiment with falling GameObjects Try variations of this exercise. Move the Sphere GameObject and the Main Camera to get the results you want. More things to try: ● Add more spheres with RigidBody Components at varying heights. ● Add other primitives and see how they behave. ● Drop objects in different places. ● Rotate the Monument GameObject. One thing to note is that you can change the properties, values and position of a selected GameObject while the game is running, but when the game is stopped all values will revert back to what they were before the game was started. This is useful to test different parameters during runtime, but if you want the changes to be permanent, you need to make the changes while the game is stopped.