Starting to learn C#, ran into a problem with the compiler. In gdscript this works because there’s no possibility that it’ll try to read a non-InputEventKey InputEvent as an InputEventKey
func remove_inputeventkey(action:String,keycode)->void:
for event in InputMap.action_get_events(action):# same as `for event in range(InputMap.action_get_events(action))`
if event is InputEventKey and event.get_physical_keycode_with_modifiers() == keycode:
InputMap.action_erase_event(action,event)
break
Whereas in C# the compiler sees the same thing and goes YOU SILLY GOOSE
public void remove_inputeventkey(string action,int keycode){
var actioninputs = InputMap.ActionGetEvents(action);
var input = actioninputs[0];
for (int i = 0; i < actioninputs.Count; i++){
input = actioninputs[i];
if (input is InputEventKey){
if (input.GetPhysicalKeycode() == keycode){
InputMap.ActionEraseEvent(action,input);
break;
}}}}
so uh yeah I know what the problem is but… what do
oh much thanks
the reason I left the name in snakecase was because I’m trying to make the autoload script it’s a part of interchangeable with one in gdscript, just add a number and boom csharp
ok yeah so uh actually it didn’t work, got some tasty errors The non-generic type 'Array' cannot be used with type arguments
and The variable 'input' is declared but never used
One of those wasn’t an error but a warning which can be ignored, and the first one wasn’t a problem with my code, but the fact that you were using the incorrect Array type. You need to pay attention because both C# and Godot has their own collections.