-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shuffling Extension (I know, not your code) returning Index out of range. #32
Comments
I think, the line where you get the error must be this one: |
I know I have to be missing something because this happens every time I try to add any additional node types. For my game, I T10-T0 are difficulty level scenes and I am trying to launch those scenes using the different node types. I think I am explaining correctly. When I use the default node types, I can launch A scene without issue. I am not good enough with scriptable objects to easily change which enemies spawn based on a difficulty curve... but I am going to figure it out eventually. But I need to learn how to successfully add new node types first. |
Do you have any node blueprints of type EliteEnemy in Default Map Config / Node Blueprints? A quick test that may help with this - you can try setting all the Randomize Nodes sliders to 0 and seeing if it eliminates the errors. |
To the best of my knowledge, the only things I changed were the code in the three scripts to add the scene/gui loading stuff and to add the ONE node type: CommonEnemy. Edit: I gotta take a nap. Might be a while before I can reply again. |
Have a good nap!
This way before the error happens, you would get a log that hints which type of node was causing an issue and how many of them you have in your MapCofig. It it says, 0 nodes, you have to fix that by making and adding a NodeBlueprint of that type into your MapConfig. |
Wasn't able to get back to it today. Will try again tomorrow. |
I'm sorry, I have autism and ADHD. If what I am doing isn't working and I feel like I am doing it correctly, I get tunnel vision and can't see what I am missing. I have to keep trying over and over until whatever I am missing clicks. I reimported the files and made a video where I retrace my steps and reproduce the error. It is eight minutes because it takes me a few to remember what I am doing again. lol. I am praying that you notice what I am missing. I couldn't figure out exactly where I needed to add that debug line, so that hasn't been tried yet. |
Thanks for sending the vid.
So, if you want to do this without introducing any errors, you do it in this order:
And it should work. Adding new NodeTypes into MapGenerator.RandomNodes is optional and not super important. You can do it later. |
As for the code that I've mentioned above, I think in your case adding it is a good idea because if you forget to do some bits of the config, it will remind you and steer you in the right direction. You can replace this line in MapGenerator.PlaceLayer:
With these lines:
Then if you ever get an error you will be warned about which NodeType caused it. |
So I was doing it backwards, taking stuff from where it belonged and rearranging it when I shouldn't have. What if I wanted to scrap them all and re-add the nodes I want in the order I want? Would Unity accept that? Or is it just best that I leave the current things where they are cause it aint broke and adding new ones will just work if I continue following your instructions? I wish I could say that I am new to all of this, but I've been putzing around with Unity since 2017. My biggest issue is that I don't know enough C# to write code from scratch. I am utilizing Bing's new notepad feature for AI generated code. I could have used it to try and figure this out... but the couple of times I tried, it told me I was doing it right. lol. That's when I came back here again. I also have the Single Player CCG kit. I was able to use it's map generator as a stand-alone feature, but it doesn't have the UI based version like yours does and when I add it to my project, the boss location is shifted too far out of the camera view no matter what I try. So I use yours. Hopefully, I am able to continue adding things to the end of the enums here and get things working. If I understood things better... I could use a single level scene and have a difficulty curve set up the scene for me. For now, I will use the multiple scenes method. yuck. lol. BTW. Thank you. |
Glad that you made some progress! You can add enums in the order that you prefer, but then literally everywhere in the Unity project you have to go and set them manually. Which is: on all the Node Blueprint objects and in the Map Config object. If you ever want to add more enum entries, remember that adding anywhere besides the end of the enum messes up the setup that you did in Unity and forces you to re-check everything again. That's why the least intrusive way is to add new entries to the end of the list. AI is still not great for coding games unfortunately. I would not fully rely on it. |
I have learned more in the last six months than I have in the last five years and that is all thanks to AI. I understand the limitations and the risks, but I would never have gotten as far as I have with this shmup than without it. It just works for my learning disability. I do my own code when I can and when I can recall what I need for the occasion and that is happening way more often than it used to. So I will respectfully continue to use AI as a crutch until I don't need to any more. Right now, what I am unsure of, as I am writing this, is how I am going to handle victories. Like how to return to the map and start act 2. I'm sure I have the right idea: set victory bool, load map scene, confirm victory bool, trigger map gen while referencing the Act2 config, and then (I think) lock the nodes to force the player to click the first one? |
By all means! Whatever works for you! So, when you win, while you are in a different scene, you can do something like:
This ensures that:
Another thing that you can do before going into the map scene is set the act number, so you could do something like:
Then you load the map scene. And in the map scene you can have a new script that would set the MapConfig based on the value in PlayerPrefs.
Add it to an object in the Map scene, link the MapManager and populate the acts array in the inspector. And when you lose the game, you can also delete the map, but set the act to 0:
Hope it helps. |
I don't know if it will let me comment on a closed topic, but here we go: Would you mind explaining to me how to unlock the next nodes after victory on the current scene? I have tried using SetAttainableNodes() but it seems to want an object reference? Which I assume are the next nodes on our path? Edit: cool. It let me re-open. I felt this was better than creating a new topic since we already covered new act and failed attempt. |
Personally, I think, it is better to create new issues if we're discussing a different topic. By design the method SetAttainableNodes() should be called automatically when the player moves or when the map is loaded. It is based on the path that player has covered on the map so far. So, unlocking next nodes should happen automatically. If it is not happening, something must be going wrong and we should investigate why it's happening. Can you describe what you're doing and what the expectation is:
|
This was a pre-emptive question. I was still setting up my win/loss UI and the question was weighing on my mind. Thank you. Here's the most recent vid I took of what I have done so far. It's not much, but it is something. |
That's looking pretty good! Congrats! Keep it up! |
Thank you very much. The ship selection screen was actually a lot of fun to work on. Getting the selected ship through the map screen and into the level was also, sarcastically, fun. When it finally worked, though, I scared my dog. lol. I literally jumped out of my seat. |
In MapPlayerTracker I have Set up my nodes like this:
MapGenerator:
NodeBlueprint:
For some reason, I continue to receive the error. Am I missing something?
The text was updated successfully, but these errors were encountered: