Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Hands-On Unity 2022 Game Development - Third Edition

You're reading from  Hands-On Unity 2022 Game Development - Third Edition

Product type Book
Published in Oct 2022
Publisher Packt
ISBN-13 9781803236919
Pages 712 pages
Edition 3rd Edition
Languages
Author (1):
Nicolas Alejandro Borromeo Nicolas Alejandro Borromeo
Profile icon Nicolas Alejandro Borromeo

Table of Contents (23) Chapters

Preface 1. Creating a Unity Project 2. Editing Scenes and Game Objects 3. Grayboxing with Terrain and ProBuilder 4. Importing and Integrating Assets 5. Introduction to C# and Visual Scripting 6. Implementing Movement and Spawning 7. Physics Collisions and Health System 8. Win and Lose Conditions 9. Implementing Game AI for Building Enemies 10. Materials and Effects with URP and Shader Graph 11. Visual Effects with Particle Systems and Visual Effect Graph 12. Lighting Using the Universal Render Pipeline 13. Full-Screen Effects with Post-Processing 14. Sound and Music Integration 15. User Interface Design 16. Creating a UI with the UI Toolkit 17. Creating Animations with Animator, Cinemachine, and Timeline 18. Optimization with Profiler, Frame Debugger, and Memory Profiler 19. Generating and Debugging an Executable 20. Augmented Reality in Unity 21. Other Books You May Enjoy
22. Index

Scripting animations

With our player’s Animator ready, it is time to do some scripting to make these parameters be affected by the actual behavior of the player and match the player’s. In this section we will do the following to achieve this:

  • Script shooting animations
  • Script movement animations

Let’s start making our characters execute the Shoot animation when necessary.

Scripting player shooting animations

So far, we have created a behavior to shoot each time we press a key, but the animation is prepared for sustained fire. We can make our PlayerShooting script shoot a bullet every X number of seconds while we keep the Fire key pressed to match the animation, instead of having to press the key repeatedly.

Let’s see how to do this:

  1. In the PlayerShooting script, add a public float field called fireRate, which will measure the seconds between bullet spawns. Remember to set this value in the Inspector of the...
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}