Help with exception when cycling Player Character Equipment
Hey all! I was getting help in a thread that I wrongly create in the bp channel. I will repost here as I think is better for visibility.
I was getting some help from @D4rk already (thank you very much by the way).
So here is what I'm trying to do:
When I press F1, I want the game to change the player hand equipment. I want to do bindings for all the available hand slots (but for now, just F1).
Here is my repository if you want to download and take a look in the whole project (4 BPs): https://github.com/pvm/EquipmentKeyBindings
In the image is the the code that gets executed when I press F1 and also I will add the exception log as well.
I'm really new to modding, I'm not sure what is wrong with the logic. @D4rk if you can take a look please, I would be very grateful!
28 Replies
Where are you running this code?
Also, the "Triggered" exec on the input action fires per tick as long as the key is pressed, you should be using "Started" or Completed"
It's in the Sub System
Nice catch, I wanted to put in the Started but I missed that, thanks!
How or when are you adding your InputMappingContext? This crash is from the EnhancedInput system, is not happy about something
I enabled it here in the Sub System
And then I just set it like this.
Just did exactly like it's in the Example Mod (Unless I missed something)
Discoconnect all the logic from the input action and log the fire event. make sure you can trigger it without crashing before you try to do anything with the equipment
I did that already and it works fine
What is that MultiCycleEquipment node? Where is that from? The target says Equipment, but you're feeding it a FGInventoryComponentEquipment object. That might be whats causing the crash
I think I understand my mistake, give me a moment, let me try something
So I used a function from another mod 😦
I'm not great at cpp, but it looks like it can possibly call Equipment->CycleEquipment( -1 ), which i don't think is valid
Maybe dont use that function lol
Very useful comment
dir
is added to mActiveEquipmentIndex
so it can be negative. Code handles negative numbers by using the last element of the arrayI didn't realised that was from another mod until you mentioned about it and I double checked. So I stopped using, but I could not find a way to call Equipment CycleEquipment trough the BPs
You need a Blueprint Function Library
Well, at least I know how to build a C++ mod now
Yeah, it's not that hard
But I will try this out as well
This other mod seems to be using a blueprint function library
I didn't understand properly, now that I have the C++ class in my project, do I need to build it other than run the Alpakit to make the node available in Unreal?
because you added the C++ through Unreal it should of done everything needed. you'll only need to compile it when you change the C++
The whole engine? because I changed the C++ code
hit "Build" not "Rebuild" and never hit "clean"
then the compiler should specifically only recompile the things that need it due to the changes
and to be clear hitting the others wont cause errors. just waste a lot of your time
Yeah, that was pretty fast, thanks:
Build completed at 3:46 AM and took 34.323 seconds
It worked!Solution
I managed to change the active equipment with the key binding shortcut key
Thank you very much @AngryBeaver (FE, CC+) @Rex @D4rk!
Soon I will post the mod in the website
Looks like we're in the same timezone 😄
Here you go if you want to take a look/try it out:
https://ficsit.app/mod/EquipmentKeyBindings
Thank you very much again @Rex [they/them] @AngryBeaver (FE, CC+) @D4rk!
Equipment Key Bindings - SMR
Allows you to bind hand equipments to specific keys in your keyboard!