Quantcast
Channel: Answers by "ThePersister"
Viewing all articles
Browse latest Browse all 99

Answer by ThePersister

$
0
0
I tried running this exact script in a simple working scene and it works just fine: using UnityEngine; using System.Collections; public class SomeScript : MonoBehaviour { private Vector3 [] Blockpositions ; private GameObject[] Blocks; private int blockslength; void Start() { Blocks = GameObject.FindGameObjectsWithTag("Blocks"); int blockslength = Blocks.Length; Vector3[] Blockpositions = new Vector3[blockslength]; for (int i = 0; i < Blocks.Length; i++) { Blockpositions[i] = Blocks[i].transform.position; Debug.Log("Easy check: " + i); } } } Also having one of the block gameobjects disabled in the scene doesn't cause any problems, it just gets skipped. The issue likely has to do with another part of your code, or the scene itself. Try running my script in a new scene, and add: - 1 Empty GameObject with the Script on it - 4 Empty GameObjects tagged with "**Blocks**" Run the scene and see if it works :) If that doesn't work, it may be an internal issue. I have Unity Pro version 4.5.0.f6, if that helps. If that doesn't cause any errors, I suggest adding more of your class' code until issues occur, if your script works, you should then have a look at the scene you're in, does it for example change an object's tag in some Start function that interferes with your code after it has been gathered into the array of correctly tagged objects. Or more likely, does one of the found blocks get Destroyed after it has entered the array, you should look into all those things :3 Best of luck, if you'd like more help, please post the rest of your script and perhaps screenshots of your screen, so we can have a look there as well for you :) Best of luck!! :D If you're satisfied with this answer, please accept it, if not, I'll be awaiting more details / questions to answer :3 Yours truly, ~ThePersister

Viewing all articles
Browse latest Browse all 99

Trending Articles



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