M
M
maxemga2020-10-10 13:06:37
Unity
maxemga, 2020-10-10 13:06:37

Why is it not displayed when spawning an object in Unity, but it does appear?

There are several given coordinates and I need the object to spawn randomly on one of them.
I implemented it like this (screenshots).
Everything works as if when I press F, objects appear on the left, but do not appear in the game itself, only if I switch to the scene menu, they appear there as they should, and when I press F to spawn the object, an error occurs:

IndexOutOfRangeException: Index was outside the bounds of the array.
RandomSpawn.SpawnRandom () (at Assets/Scripts/RandomSpawn.cs:26)
RandomSpawn.Update () (at Assets/Scripts/RandomSpawn.cs:19)

I googled how to solve it and found a lot of things, but I should have everything right.
Please help me to resolve this issue because I don't understand.
5f818787a5360758029047.png
5f818792dfa56058408471.png
5f81879c1f5c0241266986.png
5f8187a386539796158895.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DanielMcRon, 2020-10-10
@maxemga

Everything works for me
And put the code, not screenshots. If I want to debug the code, I'm not going to write from screenshots

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question