Digital FXtbook
Easy Contacts
  • Home
    • Software
    • The Author
    • Former Students Hall of Fame
    • A tribute....
    • Treasure Hunt
  • Video Game Training
    • 3d Motion Graphics >
      • Unity >
        • Unity Essentials >
          • Unity's Interface >
            • Our First Assignment
          • Modeling and Level Design >
            • The Essentials
            • The Floor is Lava Name Project
            • ProBuilder >
              • ProBuilder Pro Skater Park
              • ProBuilder Pro Skater Park 2
              • ProBuilder Image Planes
              • ProBuilder Steve Modeling
              • ProBuilder Steve Texturing
          • Programming >
            • Getting Started with Scripting
            • Default Scripting
            • Scripting a Game Object
          • Real Time Audio >
            • Adding Background Music
            • 3-d Audio effects
          • 2d Essentials >
            • 2d Game Objects
            • Objects on 2d Game Objects
        • Creative Core >
          • Introduction to Creative Core
          • Shaders and Materials
          • Lighting
          • Animation
          • VFX
          • Cameras
          • Post Processing
          • Audio
          • User Interface
          • Proto-Typing
    • C# Programming >
      • Visual Studios >
        • First Program >
          • Getting input from the User
        • Comments >
          • PsuedoCode
        • Variable Types >
          • AlphaNumeric Variables
          • Numeric Variables
          • Putting it all together
        • Operators >
          • Assignment and Arithmetic Operators >
            • Use of Parenthesis
            • When is Easter??
          • Comparison and Logical Operators >
            • Logical Data, Illogical Assignment
          • Random Class
        • Conditional Statements >
          • Number validator
          • Number tester
          • Speed Camera
        • Loops >
          • For Loops >
            • Adding Numbers
          • For Each Loops
        • Arrays >
          • Simple Arrays
          • Complex Arrays
      • Intro to Unity >
        • Unity Essentials >
          • Unity's Interface
          • The Essentials
          • Programming >
            • Getting Started with Scripting
            • Default Scripting
            • Scripting a Game Object
        • Intro to Programming 1 >
          • Player Control 1 >
            • Player Control 1.2
            • Player Control 1.3
            • Player Control 1.4
          • Player Control 2 >
            • Player Control 2.2
            • Player Control 2.3
            • Player Control 2.4
          • Player Control Challenge
        • Intro to Programming 2 >
          • Sound and Effects >
            • Sound and Effects 3.2
            • Sound and Effects 3.3
            • Sound and Effects 3.4
          • GamePlay
          • User Interface
          • Feedback and Testing
          • Next Steps
        • Intro to Programming 3 >
          • Manage Scene Flow and Data
          • Apply Object-Oriented Principles
    • Modeling and Rigging >
      • Modeling >
        • Introduction: The Temple
        • Name Text Curve
        • Character Modeling >
          • Minecraft Steve
          • Minecraft Steve UV
          • Roblox Character modeling
          • Big Daddy
          • Character Modeling Legion the Geth
          • Character Modeling Geth Armor
        • Weapons >
          • Minecraft Tools and Weapons
          • Minecraft Movie Pickaxe
          • Minecraft Movie Sword
          • Thor's Hammer
          • Hammer
          • LOL Sword
          • Sword of Light
          • Buzz Axe
          • Weapon
      • Rigging >
        • Intro to Rigging
        • Controls
        • Rigging Basics
        • Rigging Creating Skeletons
        • Rigging: Body Controls
        • Rigging: Hands
        • Rigging: Skinning
        • Smooth Skinning
      • Animation >
        • Character Animation
    • Advanced >
      • Modeling >
        • Image Planes
        • Polygon Modeling >
          • Coke Can
          • Low Polygon Character
          • Character Modeling Legion the Geth
          • Character Modeling Geth Armor
          • Face Modeling
        • NURBS Modeling >
          • Intro to NURBS
          • Lofting
          • CV Curves
          • Organic Modeling
          • Autombile
      • Linda Training >
        • Advanced Modeling >
          • Modeling Basics
          • Modeling Room Objects
      • Texturing
      • Rigging >
        • Rigging with HumanIK
        • Smooth Skinning
  • Student Films
    • Advanced Student's movies
    • Beginning Student's movies
  • Links
    • BPA >
      • BPA Computer Modeling
    • The Top Six Animation Schools
    • The Top Video Game Design Schools

Lesson 1.2 - Pedal to the Metal


Overview:
In this lesson you will make your driving simulator come alive. First you will write your very first lines of code in C#, changing the vehicle’s position and allowing it to move forward. Next you will add physics components to your objects, allowing them to collide with one another. Lastly, you will learn how to duplicate objects in the hierarchy and position them along the road

Create and apply your first script

  1. In the Project window, Right-click > Create > Folder named “Scripts”
  2. In the “Scripts” folder, Right-click > Create > C# Script named “PlayerController”
  3. Drag the new script onto the Vehicle object
  4. Click on the Vehicle object to make sure it was added as a Component in the Inspector

Add a comment in the Update() method

  1. Double-click on the script to open it in Visual Studio
  2. In the Update() method, add a comment that you will: // Move the vehicle forward

​
Picture

Give the vehicle a forward motion

  1. Under your new comment, type transform.tr, then select Translate from the autocomplete menu
  2. Type (, add 0, 0, 1 between the parentheses, and complete the line with a semicolon (;)
  3. Press Ctrl/Cmd + S to save your script, then run your game to test it

​
Picture

Use a Vector3 to move forward

  1. Delete the 0, 0, 1 you typed and use auto-complete to replace it with Vector3.forward ​
Picture

Customize the vehicle’s speed

  1. Add * Time.deltaTime and run your game
  2. Add * 20 and run your game
Picture

Add RigidBody components to objects

  1. Select the Vehicle, then in the inspector click Add Component and select RigidBody
  2. Select the Obstacle, then in the inspector click Add Component and select RigidBody
  3. In the RigidBody component properties, increase the mass of the vehicle and obstacle to be about what they would be in kilograms and test again

Duplicate and position the obstacles

  1. Click and drag your obstacle to the bottom of the list in the hierarchy
  2. Press Ctrl/Cmd+D to duplicate the obstacle and move it down the Z axis
  3. Repeat this a few more times to create more obstacles
  4. After making a few duplicates, select one in the hierarchy and hold ctrl + click to select multiple obstacles, then duplicate those
Onto the next page
Proudly powered by Weebly