Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning C# by Developing Games with Unity 2020

You're reading from   Learning C# by Developing Games with Unity 2020 An enjoyable and intuitive approach to getting started with C# programming and Unity

Arrow left icon
Product type Paperback
Published in Aug 2020
Publisher Packt
ISBN-13 9781800207806
Length 366 pages
Edition 5th Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Harrison Ferrone Harrison Ferrone
Author Profile Icon Harrison Ferrone
Harrison Ferrone
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Preface 1. Getting to Know Your Environment 2. The Building Blocks of Programming FREE CHAPTER 3. Diving into Variables, Types, and Methods 4. Control Flow and Collection Types 5. Working with Classes, Structs, and OOP 6. Getting Your Hands Dirty with Unity 7. Movement, Camera Controls, and Collisions 8. Scripting Game Mechanics 9. Basic AI and Enemy Behavior 10. Revisiting Types, Methods, and Classes 11. Introducing Stacks, Queues, and HashSets 12. Exploring Generics, Delegates, and Beyond 13. The Journey Continues 14. Pop Quiz Answers 15. Other Books You May Enjoy

Time for action – spinning animation

For the spinning animation, we want the Health_Pickup prefab to make a complete 360-degree rotation on its z axis every second, which can be done by setting three keyframes and letting Unity take care of the rest:

  1. Select Add Property | Transform and click on the + sign next to Rotation:

  1. Click on the Record button to start the animation.
  2. Place your cursor at 0:00 on the timeline but leave the Health_Pickup prefab's z rotation at 0:

a. Place your cursor at 0:30 on the timeline, and set the Z rotation to 180.

b. Place your cursor at 1:00 on the timeline, and set the Z rotation to 360:

  1. Click on the Record button to finish the animation.
  2. Click on the Play button to the right of the record button to see the animation loop.

The Health_Pickup object now rotates on the z-axis between 0, 180, and 360 degrees every second, creating the looping spin animation. If you play the game now, the animation will...

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 $19.99/month. Cancel anytime