Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Index out of bounds error. I have this error stacking for each of this script in the scene. How do i fix it?

$
0
0
Hi guys. Im new to unity and i am trying to make a simple game. I made this script for my menu and to go back to the menu from the game. However it keeps spamming the console with errors once i run the game. The script itself works fine otherwise. Is there a way to get rid of the errors? This is the error that i keep getting: UnityException: Index out of bounds. NextScene.loadNext () (at Assets/Scripts/NextScene.cs:21) NextScene.Update () (at Assets/Scripts/NextScene.cs:11) using UnityEngine; using System.Collections; public class NextScene : MonoBehaviour { public int loadThisScene; void Update() { loadNext (); } void loadNext() { RaycastHit hitInfo; Touch touch =Input.GetTouch(0); Ray ray = Camera.main.ScreenPointToRay(touch.position); if(Input.touchCount > 0 && touch.phase == TouchPhase.Began) { if (collider.Raycast (ray,out hitInfo, 10e8f)) { if(!Physics.Raycast (ray, hitInfo.distance - 0.01f)) { Application.LoadLevel(loadThisScene); } } } } }

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>