- Home /
Error: Index is out of range Unity 2D WebGL
Hi everybody. I am relatively new to Unity and have a recurring error. I am creating a simple 2D game in which the player can shoot these bullets at enemies, which are prefabs. In Unity itself, everything works fine but when I try to make a build in WebGL to play in my browser, and error keeps popping up saying my memory is out of bounds or index is out of range.
I have tried doing this on chrome, firefox, and explorer but the same thing keeps happening. I have tried searching the internet but have found no answers on how to fix this problem so far. Here is the code for my bullet script, if it helps.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WebShooter : MonoBehaviour {
public Transform firePoint;
public GameObject bulletPrefab;
void Update() {
if (Input.GetKeyDown(KeyCode.Space)) {
Shoot();
}
}
void Shoot() {
Instantiate(bulletPrefab, firePoint.position, firePoint.rotation);
}
private void OnTriggerEnter2D(Collider2D hitInfo) {
Destroy(gameObject);
}
}
I really am desperate at this point and any help at all would be appreciated. Thanks in advance.
Your answer
![](https://koobas.hobune.stream/wayback/20220612205605im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
prefab movetowards correctly in editor and windows build but not webgl build 0 Answers
RunTime Error when taking screenshot in Unity WebGL build 0 Answers
Unity webGL build changes not reflecting,Unity webgl changes is not reflecting in build 1 Answer
Creating an app for mobile and browsers 1 Answer
App gets stuck on WebGL 0 Answers