- Home /
problem uploading my game to a web page
Hello everyone, I have a doubt I created a game and I uploaded it to a web page but on the web page the ENTER key does not work for me so that the game starts and the initial screen fades, I clarify that in unity when I try it everything works for me ok and i have no problem
This is the code where I have the options of the keys
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement;
public class GameManager : MonoBehaviour { public GameObject menuPrincipal; public GameObject menuGameOver;
public float velocidad = 2;
public GameObject col;
public GameObject piedra1;
public GameObject piedra2;
public Renderer fondo;
public bool gameOver = false;
public bool start = false;
public List<GameObject> cols;
public List<GameObject> obstaculos;
// Start is called before the first frame update
void Start()
{
// Crear Mapa
for (int i = 0; i < 21; i++)
{
cols.Add(Instantiate(col, new Vector2(-8 + i, -5), Quaternion.identity));
}
// Crear Piedras
obstaculos.Add(Instantiate(piedra1, new Vector2(-3, -3), Quaternion.identity));
obstaculos.Add(Instantiate(piedra2, new Vector2(5, -3), Quaternion.identity));
}
// Update is called once per frame
void Update()
{
if (start == false)
{
if (Input.GetKeyDown(KeyCode.KeypadEnter))
{
start = true;
}
}
if (start == true && gameOver == true)
{
menuGameOver.SetActive(true);
if (Input.GetKeyDown(KeyCode.KeypadEnter))
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
}
if (start == true && gameOver == false)
{
menuPrincipal.SetActive(false);
fondo.material.mainTextureOffset = fondo.material.mainTextureOffset + new Vector2(0.1f, 0) * Time.deltaTime;
// Mover Mapa
for (int i = 0; i < cols.Count; i++)
{
if (cols[i].transform.position.x <= -10)
{
cols[i].transform.position = new Vector3(10, -5, 0);
}
cols[i].transform.position = cols[i].transform.position + new Vector3(-1, 0, 0) * Time.deltaTime * velocidad;
}
// Mover Obstaculos
for (int i = 0; i < obstaculos.Count; i++)
{
if (obstaculos[i].transform.position.x <= -10)
{
float randomObs = Random.Range(11, 18);
obstaculos[i].transform.position = new Vector3(randomObs, -3, 0);
}
obstaculos[i].transform.position = obstaculos[i].transform.position + new Vector3(-1, 0, 0) * Time.deltaTime * velocidad;
Comment
Your answer
Follow this Question
Related Questions
Putting game on website 2 Answers
Distribute terrain in zones 3 Answers
GL build won't run on Chrome 1 Answer
Textinputs not working when I implemented "Unity webGL" in VueJS Project 1 Answer