👋 Hey there! If we haven’t met before... I’m Amr, a game programmer passionate about sharing what I learn through my game development Journey, especially the lessons learned from failures and bad practices. Whether you're a beginner or an experienced dev, I hope you’ll find something here to inspire or help you out in your game development journey. ✨ Where Else You Can Find Me: I share shorter tips more regularly on: X (Twitter): x.com/AmrMakesGames Instagram: instagram.com/amrmakesgames/ TikTok: www.tiktok.com/@amrmakesgames If quick ideas and bite-sized content are your thing, come say hi there! 💌 Want to Support My Work or Dive Deeper? Over on Patreon, I share: Exclusive project files from my videos Behind-the-scenes content Access to our private Discord community Join the Patreon Family: patreon.com/AmrMakesGames Let me know if there’s something you’d like to see more of in the comments below. Your support and feedback are highly appreciated!
Hey, thank you for the video!! Since the docs about UMG Viewmodel explain the concepts (which are simple to understand), the implementation can be tricky. Your video gave me a lot of information but also a lot of questions (for example how to handle Data Assets widgets). Would you be so kind as to make a short video with a step-by-step tutorial on implementation? Thanks again✌
Hi, thanks for the feedback, It's on my list, and now I'll give it a higher priority to make a full UI system in detail, explaining view models and more concepts from the other videos.
Hello! I just wanted to say that viewmodels in 5.4 did not allow me to do a lot of things that I would like to because of crashes. I spent 2 days and was unable to use them without pain. I'd rather reinvent my wheel until they at least fix set members in property
In general, I think there is a gap between the project and some understanding how this works. I might look up more viewmodel examples to help understand this.
Yes, mainly showing both ways, and looking into how MVVM works in general can help you understand it even better. But if you've any questions, please don't hesitate to ask.
Thanks for these videos! A critique though: Lean back from the mic a bit as youre "popping" while talking. As long as you aren't too quiet you can always turn your vocal loudness up in your audio/video editor.
I checked out your project and I see that the health amount is data binded to the viewmodel. Is it optimized because the view model won’t fire every frame but only when the view model is called?
Exaclty. It is similar to using event dispatchers, but with an extra advantage that UI won't be coupled to the source of the data, and only to the view model.
Nice video, my question is: so every stat like health or stamina or inventory items for example are nomore variables on character and are only viewmodel variables or there are both, so character has the variables and then updating that also updates the viewmodel respective one?
Nice question. There is no right or wrong here, but I personally prefer to have a private variable inside my character class to have more control before I update the viewmodel.
Hi there, there are multiple ways to update health, but to give you a broader answer: to fetch any viewmodel you can use some helper functions like "GetViewFromUserWidget" and "FindViewModelInstance" from the Viewmodel Subsystem. In our example, You can see this inside BP_Character's "FetchGlobalHealthViewmodel" and "FetchHealthViewmodelFromWidget" functions. Hope that helps!
Amr, I am very confused. How are you using global view model collection in your projects? The "Get Global View Model Collection" node is missing in 5.3. I am not able to use this method of initialization. Even the documentation page for the node is missing in 5.3 while present in 5.2
Hey Cosmotect, sorry for your confusion, there has been some changes to the MVVMSubsystem in 5.3. Make sure you're using the MVVMGameSubsystem, not MVVMSubsystem. You can find an example of this in the project files I left in the description, exactly inside BP_Character's FetchHealthGlobalViewmodel function.
@@AmrMakesGames yeah, I realized that they moved and changed some things, I will try to figure it out on my own one more time, but if I can't Ill refer to your project files. Thank you for this tutorial by the way. Really looking forward to the rest of the series
@@AmrMakesGames So, I downloaded the project files, and when I tried to open it with 5.3.2 I got this error message: "The following modules are missing or built with a different engine version: Viewmodels. Would you like to rebuild them now?" If I press "yes", I then get this error: "Viewmodels could not be compiled. Try rebuilding from source manually."
Another question I have is this: Say I have an actor component "BPC_EntityHealth" which handles health related logic for the entity. How do I get it to write to the viewmodel instance which is being read by the UI? Is it okay to have the BPC coupled with the viewmodel? Or should I avoid that?
It's okay to couple the component to the viewmodel, and the UI to the viewmodel, but not the component to the UI. That is the purpose of viewmodels, being a medium for game and UI communication.
Hi Amr! I have downloaded the project file view models but it showing error cant compile, it says i need to rebuild from source manually. I did from VS and still showing build error.. please update the project link. Thanks!!
@@AmrMakesGames I am using UE5.3.2 (latest build) but still not working even after regen VS project files and saying build complete then when I open the project it shows "Viewmodels could not be compiled. Try rebuilding from source manually." So I tried building from VS 2022 and this is what says: 1>------ Build started: Project: Viewmodels, Configuration: DebugGame_Editor x64 ------ 1>Building ViewmodelsEditor... 1>Using Visual Studio 2022 14.39.33521 toolchain (C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519) and Windows 10.0.18362.0 SDK (C:\Program Files (x86)\Windows Kits\10). 1>Determining max actions to execute in parallel (6 physical cores, 12 logical cores) 1> Executing up to 6 processes, one per physical core 1> Requested 1.5 GB memory per action, 4.63 GB available: limiting max parallel actions to 3 1>------ Building 10 action(s) started ------ 1>[1/10] Compile [x64] SharedPCH.Engine.NonOptimized.Cpp20.cpp 1>E:\UE_5.3\Engine\Source\predefined C++ types (compiler internal)(420): error C2248: 'FHazardPointerCollection::FHazardRecord::FHazardRecord': cannot access private member declared in class 'FHazardPointerCollection::FHazardRecord' 1>E:\UE_5.3\Engine\Source\Runtime\Core\Public\Experimental\Containers\HazardPointer.h(86): note: see declaration of 'FHazardPointerCollection::FHazardRecord::FHazardRecord' 1>E:\UE_5.3\Engine\Source\Runtime\Core\Public\Experimental\Containers\HazardPointer.h(77): note: see declaration of 'FHazardPointerCollection::FHazardRecord' 1>E:\UE_5.3\Engine\Source\predefined C++ types (compiler internal)(420): note: the template instantiation context (the oldest one first) is 1>E:\UE_5.3\Engine\Source\Runtime\Core\Public\Experimental\Containers\HazardPointer.h(133): note: see reference to function template instantiation 'void __builtin_array_init_helper(_T *,size_t) noexcept()' being compiled 1> with 1> [ 1> _T=FHazardPointerCollection::FHazardRecord 1> ] 1>Total time in Parallel executor: 22.33 seconds 1>Total execution time: 23.17 seconds 1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.MakeFile.Targets(44,5): error MSB3073: The command "E:\UE_5.3\Engine\Build\BatchFiles\Build.bat ViewmodelsEditor Win64 DebugGame -Project="D:\Ahmed\UE5\My Projects\Viewmodels\Viewmodels.uproject" -WaitMutex -FromMsBuild" exited with code 6. 1>Done building project "Viewmodels.vcxproj" -- FAILED. ========== Build: 0 succeeded, 1 failed, 10 up-to-date, 0 skipped ========== ========== Build completed at 8:23 PM and took 23.624 seconds ==========
Sorry for the confusion, a viewmodel can be created in multiple instances and doesn’t need to be one only. The example we discussed at 06:00 is just for consistency and performance because they all read the same source of data. On the other hand, a singleton would be something like the MVVM subsystem, which is a single global instance.
👋 Hey there! If we haven’t met before...
I’m Amr, a game programmer passionate about sharing what I learn through my game development Journey, especially the lessons learned from failures and bad practices. Whether you're a beginner or an experienced dev, I hope you’ll find something here to inspire or help you out in your game development journey.
✨ Where Else You Can Find Me:
I share shorter tips more regularly on:
X (Twitter): x.com/AmrMakesGames
Instagram: instagram.com/amrmakesgames/
TikTok: www.tiktok.com/@amrmakesgames
If quick ideas and bite-sized content are your thing, come say hi there!
💌 Want to Support My Work or Dive Deeper?
Over on Patreon, I share:
Exclusive project files from my videos
Behind-the-scenes content
Access to our private Discord community
Join the Patreon Family: patreon.com/AmrMakesGames
Let me know if there’s something you’d like to see more of in the comments below.
Your support and feedback are highly appreciated!
Hell of a well made tutorial! Thanks! I'm coming from Unity and am pretty excited about this as a replacement for Scriptable Objects as a middle man.
Please continue making videos on UI it is a big help.
Wow totally new stuff never knew about this and it looks so cool and useful, i think I'll start fiddling around with it and see where it leads to
Hey, thank you for the video!! Since the docs about UMG Viewmodel explain the concepts (which are simple to understand), the implementation can be tricky. Your video gave me a lot of information but also a lot of questions (for example how to handle Data Assets widgets). Would you be so kind as to make a short video with a step-by-step tutorial on implementation? Thanks again✌
Hi, thanks for the feedback,
It's on my list, and now I'll give it a higher priority to make a full UI system in detail, explaining view models and more concepts from the other videos.
Always great stuff brother keep it up ❤
Always thankful for your support brother!
I didn't understand View Models at first but this video helped me a lot, Amazing Video great job man 🙌
Appreciate it a lot ya Megzzz! 🙏🙏❤️
Hello! I just wanted to say that viewmodels in 5.4 did not allow me to do a lot of things that I would like to because of crashes. I spent 2 days and was unable to use them without pain. I'd rather reinvent my wheel until they at least fix set members in property
Thank you for pointing that out, I didn't use them in 5.4 personally.
What was your intent to have both C++ VM_health and a VM_health blue print? Are they connected? Or are you just showing how to do both?
In general, I think there is a gap between the project and some understanding how this works. I might look up more viewmodel examples to help understand this.
Yes, mainly showing both ways, and looking into how MVVM works in general can help you understand it even better. But if you've any questions, please don't hesitate to ask.
Thanks for these videos! A critique though: Lean back from the mic a bit as youre "popping" while talking. As long as you aren't too quiet you can always turn your vocal loudness up in your audio/video editor.
Thanks for the tip!
I checked out your project and I see that the health amount is data binded to the viewmodel. Is it optimized because the view model won’t fire every frame but only when the view model is called?
Exaclty.
It is similar to using event dispatchers, but with an extra advantage that UI won't be coupled to the source of the data, and only to the view model.
Nice video, my question is: so every stat like health or stamina or inventory items for example are nomore variables on character and are only viewmodel variables or there are both, so character has the variables and then updating that also updates the viewmodel respective one?
Nice question. There is no right or wrong here, but I personally prefer to have a private variable inside my character class to have more control before I update the viewmodel.
I can't figure out how to update the Health value correctly, for example from another actor? Thanks
Hi there, there are multiple ways to update health, but to give you a broader answer: to fetch any viewmodel you can use some helper functions like "GetViewFromUserWidget" and "FindViewModelInstance" from the Viewmodel Subsystem.
In our example, You can see this inside BP_Character's "FetchGlobalHealthViewmodel" and "FetchHealthViewmodelFromWidget" functions.
Hope that helps!
@@AmrMakesGames Thank you for your reply and thank you for such rich videos.
Amr, I am very confused. How are you using global view model collection in your projects?
The "Get Global View Model Collection" node is missing in 5.3. I am not able to use this method of initialization. Even the documentation page for the node is missing in 5.3 while present in 5.2
Hey Cosmotect, sorry for your confusion, there has been some changes to the MVVMSubsystem in 5.3. Make sure you're using the MVVMGameSubsystem, not MVVMSubsystem.
You can find an example of this in the project files I left in the description, exactly inside BP_Character's FetchHealthGlobalViewmodel function.
@@AmrMakesGames yeah, I realized that they moved and changed some things, I will try to figure it out on my own one more time, but if I can't Ill refer to your project files. Thank you for this tutorial by the way. Really looking forward to the rest of the series
@@cosmotect glad I could help and good luck with it!
@@AmrMakesGames So, I downloaded the project files, and when I tried to open it with 5.3.2 I got this error message: "The following modules are missing or built with a different engine version: Viewmodels. Would you like to rebuild them now?"
If I press "yes", I then get this error: "Viewmodels could not be compiled. Try rebuilding from source manually."
@cosmotect do you have Visual Studio installed, and can you try searching how to compile Unreal C++ code?
Another question I have is this:
Say I have an actor component "BPC_EntityHealth" which handles health related logic for the entity. How do I get it to write to the viewmodel instance which is being read by the UI? Is it okay to have the BPC coupled with the viewmodel? Or should I avoid that?
It's okay to couple the component to the viewmodel, and the UI to the viewmodel, but not the component to the UI. That is the purpose of viewmodels, being a medium for game and UI communication.
@@AmrMakesGames gotcha, thanks :)
Hi Amr! I have downloaded the project file view models but it showing error cant compile, it says i need to rebuild from source manually. I did from VS and still showing build error.. please update the project link. Thanks!!
Hey Ahmad, thank you for letting me know.
Project link is updated!
@@AmrMakesGames Still not working its the same issue still?
@@AhmadRocks Can you please double-check it? What engine version are you using and Can you show me the build error from VS?
@@AmrMakesGames I am using UE5.3.2 the latest one, Also can you send me your twitter username or email? to send screenshots of it?
@@AmrMakesGames I am using UE5.3.2 (latest build) but still not working even after regen VS project files and saying build complete then when I open the project it shows "Viewmodels could not be compiled. Try rebuilding from source manually." So I tried building from VS 2022 and this is what says:
1>------ Build started: Project: Viewmodels, Configuration: DebugGame_Editor x64 ------
1>Building ViewmodelsEditor...
1>Using Visual Studio 2022 14.39.33521 toolchain (C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519) and Windows 10.0.18362.0 SDK (C:\Program Files (x86)\Windows Kits\10).
1>Determining max actions to execute in parallel (6 physical cores, 12 logical cores)
1> Executing up to 6 processes, one per physical core
1> Requested 1.5 GB memory per action, 4.63 GB available: limiting max parallel actions to 3
1>------ Building 10 action(s) started ------
1>[1/10] Compile [x64] SharedPCH.Engine.NonOptimized.Cpp20.cpp
1>E:\UE_5.3\Engine\Source\predefined C++ types (compiler internal)(420): error C2248: 'FHazardPointerCollection::FHazardRecord::FHazardRecord': cannot access private member declared in class 'FHazardPointerCollection::FHazardRecord'
1>E:\UE_5.3\Engine\Source\Runtime\Core\Public\Experimental\Containers\HazardPointer.h(86): note: see declaration of 'FHazardPointerCollection::FHazardRecord::FHazardRecord'
1>E:\UE_5.3\Engine\Source\Runtime\Core\Public\Experimental\Containers\HazardPointer.h(77): note: see declaration of 'FHazardPointerCollection::FHazardRecord'
1>E:\UE_5.3\Engine\Source\predefined C++ types (compiler internal)(420): note: the template instantiation context (the oldest one first) is
1>E:\UE_5.3\Engine\Source\Runtime\Core\Public\Experimental\Containers\HazardPointer.h(133): note: see reference to function template instantiation 'void __builtin_array_init_helper(_T *,size_t) noexcept()' being compiled
1> with
1> [
1> _T=FHazardPointerCollection::FHazardRecord
1> ]
1>Total time in Parallel executor: 22.33 seconds
1>Total execution time: 23.17 seconds
1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.MakeFile.Targets(44,5): error MSB3073: The command "E:\UE_5.3\Engine\Build\BatchFiles\Build.bat ViewmodelsEditor Win64 DebugGame -Project="D:\Ahmed\UE5\My Projects\Viewmodels\Viewmodels.uproject" -WaitMutex -FromMsBuild" exited with code 6.
1>Done building project "Viewmodels.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 10 up-to-date, 0 skipped ==========
========== Build completed at 8:23 PM and took 23.624 seconds ==========
Is there a difference between a Viewmodel and a singleton? The reason why I ask is because the core idea of they can only have one sounds similar
Sorry for the confusion, a viewmodel can be created in multiple instances and doesn’t need to be one only.
The example we discussed at 06:00 is just for consistency and performance because they all read the same source of data.
On the other hand, a singleton would be something like the MVVM subsystem, which is a single global instance.
@@AmrMakesGames Do all instance still refer to the same variable?
In that example, yes
Thanks
A pop filter would go a long way
Definitely need to invest in one soon!
@@AmrMakesGames still a great video!