#Issues with "invalid access to 0" in an Array InputEvent
1 messages · Page 1 of 1 (latest)
It just means the array is empty. Perhaps "advance_text" is the incorrect name for your input map? Or perhaps you don't have any keys set up for it right now?
You can add a breakpoint to the code to see the values for yourself by clicking on the line number right after assigning "action_events" (screenshot attached).
Depending on how you are setting things up, you may want to check if the array is empty and return a default button text anyways (in case there is no key assigned)
trying
by breakpoint, do you mean indention?
Ok, set the breakpoint, how would I go about finding the value
action_name should assign a string value as indicated by the match number function. I don't know why it isn't displaying any values
https://www.youtube.com/watch?v=vNQBFn0faws
This is the tutorial I'm following, and 16:52 is when this specific line of code is typed
In this video we'll be adding to the options menu we previously created by adding a scrolling controls settings menu that let's us add as many controls or key binds as we need to and rebind them if we choose to in-game.
In future videos I'll be adding much more to the options menu, stylizing it and finally showing off how to create settings spe...
When the game pauses for your breakpoint, the current values of variables in the script are found at the bottom of the inspector (in the debug pane).
What I'm seeing
Does action_events appear in that variable list?
Also, are you 100% sure there is an action with the exact same name in Project>Settings>Input Map?
Will respond after work
Assuming you mean filter stack variables, yes
I do not see any evidence of the name here
You're supposed to be searching for the input action called advance_text.
Unless im missing something the tutorial doesn't seem to explicitly state you need to make the input action first. It expected you to already make one.
Did you have the action added yet
I never recall being told to make the input action global no
And I’ve been doing his tutorials in order
You need to make the input action first. Name it advance_text. And then configure what key to trigger that input.
Ok
Considering that I’m setting keybinds, is there a particular key I should consider for triggers?
Usually for triggers, a commonly used keybind is E F or Enter
Ok
So would I add the trigger in my code?
He doesn’t go over specifically how to bind specific keys, moreso just how to have the code register the keycode associated with the key pressed
You need to add at least one keybind as the default, it can be whatever as long as theres at least one. e.g. for Attack action you have Z as the default keybind.
Just add it on the input map, think of it from the player prespective
When you play a game for the first time there will always be a default keybind.
W for Up S for Down A for Left D for right. And then the player can change that keybind to anything elses.
First of all check if your event is actually exist in the InputMap. Second check if you actually added an event into the action. Third please give more info other than "it doesn't work" because it could be anything when we don't have more info on why it doesn't work.
You could give us a screenshot of what the InputMap looks like and what your action looks like. You could give us a screenshot of a code that checks if the Input actually exist. Anything that gives more insight on your situation
Did you use a breakpoint to see what Input is being checked yet.
Okay so that means we are on the right track. Whats your current code looks like
Unchanged aside from the input added for the map
Whats weird is that I followed the tutorial step-by-step and it worked fine for him
So either this is a thing with the new version of Godot, or I somehow missed something despite watching it three times
At line 26. Add this before the InputMp.action_get_events
assert(InputMap.has_action(action_name), "There is no action called %s" % [action_name])
You're only adding 1 action. That error could be caused by another action you haven't added yet.
Because in this code you have 3 action. advance_text skip_dialogue and access_menu you need to add all of them
Yeah, the assertion just failed for that reason
Let mee try adding them now
It works
Gonna leave a comment regarding this on the video. Maybe I'll get some feedback
So, what's the string for in the assert line?
Hm? Which string
If you refer to the second parameter "There is no action called %s" % [action_name]) it will print what action that are missing, if you dont put that comment it just gonna says assertion failed without telling you what failed.
Even if he doesn't, at least it will help others who will came into the same situation.
I wonder if this is an issue of Godot being updated. Will keep an eye out
It isn't, i've watched parts of the video and the only time they brought up InputMap window is around 9:01. So i assume this tutorial is made with the assumption the viewer already made their action in the input map.