Skip to Content
Mastering UI Development with Unity
book

Mastering UI Development with Unity

by Dr. Ashley Godbold
April 2018
Beginner content levelBeginner
468 pages
11h 7m
English
Packt Publishing
Content preview from Mastering UI Development with Unity

GetAxis

If you're looking for a function that will trigger continuously without any breaks between firing, you want to use GetAxis() rather than GetButton(). GetButton() is good for buttons you want to hold down but want a slight pause between events firing (think holding down a fire button, and the gun shoots bullets with breaks in between them). GetAxis() works better for events involving movement because of this continuous frame-rate independent execution.

GetAxis() works a bit differently, as it returns a float value rather than a Boolean, such as GetButton(). It is also best suited within an Update() function. So, for example, you can check whether the horizontal movement is occurring, as follows:

void Update () { float horizontalValue= ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Game Development with Unity for .NET Developers

Game Development with Unity for .NET Developers

Jiadong Chen
Unity UI Cookbook

Unity UI Cookbook

Francesco Sapio

Publisher Resources

ISBN: 9781787125520Supplemental Content