Overriding UMVVMViewModelBase class Corrupting BPs

fabsgrip11
Tue, 19 Mar 2024 14:26:31 +0000
UI

Hello,

For the better part of a week I’ve been exploring and learning the about the MVVM plugin for UE5.3. on the main branch of the engine and have encountered issues with overriding the UMVVMViewModelBase class in C++ and experiencing issues with unhandled exceptions and corrupted BPs.

At first I wasn’t sure of what was causing the corruption but I believe I’ve gathered enough information to show reproduction steps for the error occurring on my end:

1. First step is to create an empty or template project with the MVVM plugin enabled.

2. Next override the UMVVMViewModelBase C++ class and add any variables with getters, setters or functions desired. (In my case I used the class provided in the Unreal Documentation page for MVVM).

3. Run the project and create BP object from the overriden ViewModel class you just created and add it to any Widget and bind a function to a value (Again, in my case I used a widget with a progress bar and bound its percent value to the GetHealthPercent function in the UVMCharacterHealth class provided above).

4. Next is to create a reference to the VM BP anywhere in the code and add to the MVVM subsystem.

5. Going back to the overriden C++ VM class, create a a new variable, go to one of the created Getters, Setters or Functions you’ve made and replace the variable related to it with the one you just created.

6. Rebuild the project and Run it, notice that an exception is hit on the overriden VM C++ class and the VM BP is corrupted. (Live Coding also yielded the result sometimes but it was rare in comparison to just rebuilding the project).

1 post - 1 participant