Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Unity Certified Programmer Exam Guide - Second Edition

You're reading from  Unity Certified Programmer Exam Guide - Second Edition

Product type Book
Published in May 2022
Publisher Packt
ISBN-13 9781803246215
Pages 766 pages
Edition 2nd Edition
Languages
Author (1):
Philip Walker Philip Walker
Profile icon Philip Walker

Table of Contents (17) Chapters

Preface 1. Chapter 1: Setting Up and Structuring Our Project 2. Chapter 2: Adding and Manipulating Objects 3. Chapter 3: Managing Scripts and Taking a Mock Test 4. Chapter 4: Applying Art, Animation, and Particles 5. Chapter 5: Creating a Shop Scene for Our Game 6. Chapter 6: Purchasing In-Game Items and Advertisements 7. Chapter 7: Creating a Game Loop and Mock Test 8. Chapter 8: Adding Custom Fonts and UI 9. Chapter 9: Creating a 2D Shop Interface and In-Game HUD 10. Chapter 10: Pausing the Game, Altering Sound, and a Mock Test 11. Chapter 11: Storing Data and Audio Mixer 12. Chapter 12: NavMesh, Timeline, and a Mock Test 13. Chapter 13: Effects, Testing, Performance, and Alt Controls 14. Chapter 14: Full Unity Programmer Mock Exam 15. Other Books You May Enjoy Appendix

Animating our three-dimensional enemies

Here's a really easy, quick animation with the script for your enemies. Currently, the enemies just move up and down in a wave pattern. However, the units themselves remain static.

Let's give our enemies a bit of extra life with some code:

  1. In the Project window, go to Assets/Prefab/Enemies.
  2. Double-click on the enemy_wave prefab and select the enemy_wave_ring in the Hierarchy window.
  3. In the Inspector window, click on the Add Component button.
  4. Click on New Script at the bottom of the dropdown.
  5. Name the new C# script BasicEnemyRotate.
  6. Then, enter this code:
    using UnityEngine;
    public class BasicEnemyRotate : MonoBehaviour 
    {
     [SerializeField]
     float speed = 0;
    void Update ()
      {
       transform.Rotate(Vector3.left*Time.deltaTime*speed);
      }
    }

This is a tiny script that animates the part of our enemy. There are two things to look closely at:

  • The variable is a private...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}