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?
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.
oh yes… is very but very good respons… but im not understand this concept:
originally code for Roll a Ball of unity is
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
public float speed;
private Rigidbody rb;
void Start ()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rb.AddForce (movement * speed);
}
}
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?
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.
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…
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
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour
{
// Using same speed reference in both, desktop and other devices
public float speed =1000;
void Main ()
{
// Preventing mobile devices going in to sleep mode
//(actual problem if only accelerometer input is used)
Screen.sleepTimeout = SleepTimeout.NeverSleep;
}
void Update()
{
if (SystemInfo.deviceType == DeviceType.Desktop)
{
// Exit condition for Desktop devices
if (Input.GetKey("escape"))
Application.Quit();
}
else
{
// Exit condition for mobile devices
if (Input.GetKeyDown(KeyCode.Escape))
Application.Quit();
}
}
void FixedUpdate ()
{
if (SystemInfo.deviceType == DeviceType.Desktop)
{
// Player movement in desktop devices
// Definition of force vector X and Y components
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
// Building of force vector
Vector3 movement = new Vector3 (moveHorizontal,0.0f,moveVertical);
// Adding force to rigidbody
rigidbody.AddForce(movement * speed * Time.deltaTime);
}
else
{
// Player movement in mobile devices
// Building of force vector
Vector3 movement = new Vector3 (Input.acceleration.x, 0.0f, Input.acceleration.y);
// Adding force to rigidbody
rigidbody.AddForce(movement * speed * Time.deltaTime);
}
}
}