Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Ouya Unity Game Development

You're reading from  Ouya Unity Game Development

Product type Book
Published in Oct 2013
Publisher Packt
ISBN-13 9781783559701
Pages 118 pages
Edition 1st Edition
Languages
Author (1):
Gary Riches Gary Riches
Profile icon Gary Riches

Making the character move


Our game is shaping up nicely, we have the level-building code complete and the camera will, in theory, follow the player around when they move. Let's put that to the test.

As in the previous chapter, we'll get all the input working with the keyboard and then implement the Ouya input.

We are going to make it so the person playing the game can turn left, turn right, and move forward. This will always happen one tile at a time.

Edit your Sokoban script file and add the following code below the int amountOfCrates = 0; line:

GameObject theCrate;
bool isPlayerMoving;
bool isPlayerRotating;
int rotationSpeed;
int movingSteps;
int tRow;
int tCol;

The items these variables will represent are:

  • theCrate: This is a reference to the crate game object that the player is currently pushing

  • isPlayerMoving: This is a Boolean that will be set to true if the player is moving, else it will be false

  • isPlayerRotating: This is a Boolean that will be set to true if the player is moving, else...

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}