O'Reilly logo

Learning Unity iOS Game Development by Kyle Langley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Writing the character code and connecting the PlayerInput class to it

The last stage of the character is its code class. The code class will receive input from the PlayerInput class we wrote earlier, so the character can be controlled through the input and filter out the type of GameObjects that collided with from the parent of that collider type.

Perform the following steps:

To start with, navigate to the Assets/Scripts folder and right-click on it. Select Create and then C# Script. Name it Character.

Next, we need to give our PlayerInput class a reference to our character. To perform this, navigate to the Assets/Scripts folder and double-click on the PlayerInput.cs file to open it.

At the top of the class, under the SimpleTouch struct, add the following ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required