Search Unity

Roll-a-Ball Tutorial for iOS?

Discussion in 'Getting Started' started by aguirren, Apr 21, 2015.

  1. aguirren

    aguirren

    Joined:
    Apr 21, 2015
    Posts:
    2
    Hello,

    I am working on the roll-a-ball tutorial, and had a question specifically regarding deployment to the iOS platform. Is it easy/feasible to port this game to iOS with controls using the gyroscope/touchscreen?

    My goal is to create the game in such a way that the ball can be controlled by tilting the iPhone/iPad. The tutorial seems pretty straightforward, but as a beginner, I would like to know the work involved in distributing to iOS in this manner.

    Any help is appreciated
     
  2. Mumumurilo

    Mumumurilo

    Joined:
    Apr 1, 2015
    Posts:
    3
    I have developed a Roll a Ball version for Android, but it moves the ball with a joystick instead of the tilting. I believe it works the same for iOS. If you are interested, look up for Unity Ready Assets or Mobile Single Stick Input. It is very easy to implement, you just need to import the prefabs and scripts, drag and drop it to the hierarchy and change the PlayerController.cs script a little bit:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.UI;
    4. using UnityStandardAssets.CrossPlatformInput; //Add this line
    5.  
    6. public class PlayerController : MonoBehaviour {
    7.     public float speed;
    8.     public Text countText;
    9.     private int count = 0;
    10.     public Text winText;
    11.  
    12.     void Start(){
    13.         setCountText();
    14.         winText.text = "";
    15.     }
    16.  
    17.     void FixedUpdate(){
    18.         float moveHorizontal = CrossPlatformInputManager.GetAxis ("Horizontal"); //Changed from Input.GetAxis
    19.         float moveVertical = CrossPlatformInputManager.GetAxis ("Vertical"); //Changed from Input.GetAxis
    20.  
    21.         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    22.      
    23.         GetComponent<Rigidbody>().AddForce (movement * speed * Time.deltaTime);
    24.     }
    25.  
    26.  
    27. //... the code goes on
     
  3. aguirren

    aguirren

    Joined:
    Apr 21, 2015
    Posts:
    2
    Thanks for your reply! I can't seem to find the Mobile Single Stick Input. Can you give me a link please?

    I appreciate your help