Hi, for my game I want to send out certain commands in my code when the android screen is touched as my app is for android. What line would I use to do that? Would it be if(GetMouseDown) or something like that?
Please help, I want to make it so that when the top half of the screen is touched the player moves up but if the bottom half of the screen is touched the cube moves down. Or if there is a way to use an else if statement to make the player move up or down depending on their current position on the y axis. Here is my code so far ( it only makes the player go down once and it won’t go back up, I tried using a goto loop but it crashed unity)
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour
{
// Start in portait mode
void Start () {
Screen.orientation = ScreenOrientation.Portrait;
}
public GameObject PlayerGameObject;
public GameObject GroundObject;
//Movement
public float speed;
public float jump;
float moveVelocity;
void Update ()
{
//Flipping
if(Input.GetKeyDown(KeyCode.Space))
{
for (int i = 3; PlayerGameObject.transform.position.y < i; )
{
PlayerGameObject.transform.position = new Vector3 (4, 4, 0);
PlayerGameObject.transform.position = new Vector3 (PlayerGameObject.transform.position.x, 4, PlayerGameObject.transform.position.z);
}}
if(Input.GetKeyDown(KeyCode.Space))
{
for (int i = 3; PlayerGameObject.transform.position.y > i; )
{
PlayerGameObject.transform.position = new Vector3 (4, 2, 0);
PlayerGameObject.transform.position = new Vector3 (PlayerGameObject.transform.position.x, 2, PlayerGameObject.transform.position.z);
}}
}
}