Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Learn Unity3D

Discussion in 'Android' started by Deathcrew, Nov 13, 2016.

  1. Deathcrew

    Deathcrew

    Joined:
    Nov 12, 2016
    Posts:
    7
    hello to all, im new here... and i want to learn make game for android!!!
    first to all i want to see the basics with the official tutorial of Unity3D ... but... if i want to build the project "roll a ball" for android device... i need more script for touch, or its ok the basic script of the tutorial for export and try with android device?

    my basics csharp is 0... help me ^_^
     
  2. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,778
    First you need to learn C# and C#.net for understanding programming concepts. Then you can search on answers.unity3d.com to find a lot of scripts and solutions for your problems.
     
  3. Deathcrew

    Deathcrew

    Joined:
    Nov 12, 2016
    Posts:
    7
    oh yes... is very but very good respons... but im not understand this concept:
    originally code for Roll a Ball of unity is

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class PlayerController : MonoBehaviour {
    5.  
    6.     public float speed;
    7.  
    8.     private Rigidbody rb;
    9.  
    10.     void Start ()
    11.     {
    12.         rb = GetComponent<Rigidbody>();
    13.     }
    14.  
    15.     void FixedUpdate ()
    16.     {
    17.         float moveHorizontal = Input.GetAxis ("Horizontal");
    18.         float moveVertical = Input.GetAxis ("Vertical");
    19.  
    20.         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    21.  
    22.         rb.AddForce (movement * speed);
    23.     }
    24. }
    i want modify this movement ( mouse sx+arrow keyboard) with Input.GetTouch .... for it i replace Input.GetAxis with Input.GetTouch ... but not work... why? i must created a new code, or i can modify it for basic lessons of unity?

    thanks to all
     
  4. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,778


    You need more experience ,specially about inputs.
    Also mobile input system is harder than PC. you need to first start working on PC game programming for leaning.
     
  5. Deathcrew

    Deathcrew

    Joined:
    Nov 12, 2016
    Posts:
    7
    i appreciate that you answer to me... but give me a solutione, and not to continue to talk a experience... experience and experience... give me a way for adjust my problem and no blablabla...
     
  6. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,778
    That's what all newcomers say.
    I'm sorry. You can wait for answer...
     
  7. Deathcrew

    Deathcrew

    Joined:
    Nov 12, 2016
    Posts:
    7
    ok ... i solved my question... try try try and search search seach... below the code for run the initially project Roll a Ball of unity for smartphone... with SPEED SETUP (like to tutorial of unity) NO SLEEP MODE, EXIT PROGRAM FROM THE DEVICE, PLAYER MOVEMENT AND VECTOR3 FOR MOBILE!!! I found on post of Uniblack user... tnx

    Code (CSharp):
    1.  using UnityEngine;
    2. using System.Collections;
    3. public class PlayerController : MonoBehaviour
    4. {
    5.      // Using same speed reference in both, desktop and other devices
    6.      public float speed =1000;
    7.      void Main ()
    8.          {
    9.                  // Preventing mobile devices going in to sleep mode
    10.                  //(actual problem if only accelerometer input is used)
    11.                  Screen.sleepTimeout = SleepTimeout.NeverSleep;
    12.          }
    13.      void Update()
    14.          {
    15.          
    16.          if (SystemInfo.deviceType == DeviceType.Desktop)
    17.          {
    18.              // Exit condition for Desktop devices
    19.              if (Input.GetKey("escape"))
    20.                  Application.Quit();
    21.          }
    22.          else
    23.          {
    24.              // Exit condition for mobile devices
    25.              if (Input.GetKeyDown(KeyCode.Escape))
    26.                  Application.Quit();          
    27.          }
    28.        
    29.        
    30.          }
    31.    
    32.    
    33.      void FixedUpdate ()
    34.          {
    35.              if (SystemInfo.deviceType == DeviceType.Desktop)
    36.              {
    37.                      // Player movement in desktop devices
    38.                  // Definition of force vector X and Y components
    39.                  float moveHorizontal = Input.GetAxis("Horizontal");
    40.                  float moveVertical = Input.GetAxis("Vertical");
    41.                  // Building of force vector
    42.                  Vector3 movement = new Vector3 (moveHorizontal,0.0f,moveVertical);
    43.                  // Adding force to rigidbody
    44.                  rigidbody.AddForce(movement * speed * Time.deltaTime);
    45.              }
    46.              else
    47.              {
    48.                      // Player movement in mobile devices
    49.                  // Building of force vector
    50.                  Vector3 movement = new Vector3 (Input.acceleration.x, 0.0f, Input.acceleration.y);
    51.                  // Adding force to rigidbody
    52.                  rigidbody.AddForce(movement * speed * Time.deltaTime);
    53.              }
    54.          }
    55.        
    56. }