I have no idea if I am getting this error because of some new scripting change (For example but completely irrelevant the SceneManager change) but everytime I try to track the last touch’s position, it never works.
Here’s the code I made to spawn a ball at the touch’s location (Worked in old Unity version):
using UnityEngine;
using System.Collections;
public class ballSpawner : MonoBehaviour {
// Use this for initialization
void Start () {
}
public GameObject ball;
public bool tapped = false;
public Vector2 touchLocation;
void touchCheck () {
if (Input.GetButtonDown ("Fire1" )) {
tapped = true;
ball = Instantiate(ball);
ball.transform.position = touchLocation;
} else if (Input.GetButtonUp ("Fire1")) {
tapped = false;
}
}
// Update is called once per frame
void Update () {
Vector2 touchLocation = Input.GetTouch(0).position;
touchCheck();
}
}
While fiddling with that and receiving an error stating “ArgumentException: Index out of bounds. ballSpawner.Update () (at Assets/Scripts/ballSpawner.cs:29)”
Please somebody inform me if there was some change or so because it’s destroying my brain and my code. D;