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

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

Product type Book
Published in Jun 2023
Publisher Packt
ISBN-13 9781804613726
Pages 480 pages
Edition 3rd Edition
Languages
Author (1):
John P. Doran John P. Doran
Profile icon John P. Doran

Table of Contents (21) Chapters

Preface 1. Part 1: Gameplay/Development Setup
2. Chapter 1: Building Your Game 3. Chapter 2: Project Setup for Android and iOS Development 4. Part 2: Mobile-Specific Features
5. Chapter 3: Mobile Input/Touch Controls 6. Chapter 4: Resolution-Independent UI 7. Chapter 5: Advanced Mobile UI 8. Chapter 6: Implementing In-App Purchases 9. Chapter 7: Advertising Using Unity Ads 10. Chapter 8: Integrating Social Media into Our Project 11. Part 3: Game Feel/Polish
12. Chapter 9: Keeping Players Involved with Notifications 13. Chapter 10: Using Unity Analytics 14. Chapter 11: Remote Config 15. Chapter 12: Improving Game Feel 16. Chapter 13: Building a Release Copy of Our Game 17. Chapter 14: Submitting Games to App Stores 18. Chapter 15: Augmented Reality 19. Index 20. Other Books You May Enjoy

Using the accelerometer

Another type of input that mobile has, but PC doesn’t, is the accelerometer. This allows you to move in the game by tilting the physical position of the phone. The most popular example of this is likely the movement of the player in games such as Lima Sky’s Doodle Jump and Gameloft’s Asphalt series. To do something similar, we can retrieve the acceleration of our device with the Input.acceleration property and use it to move the player. Let’s look at the steps to do just that:

  1. We may want to allow our designers to set whether they want to use the Accelerometer mode or ScreenTouch, which we used previously. With that in mind, let’s create a new enum with the possible values to place in the PlayerBehaviour script above the Swipe Properties header:
    [Tooltip("How fast the ball moves forwards
        automatically")]
    [Range(0, 10)]
    public float rollSpeed = 5;
    public enum MobileHorizMovement
    {
     ...
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 €14.99/month. Cancel anytime}