Epic's engine and content terms
Unreal Engine EULA: selling code built on Unreal
Updated
Epic leaves your own work with you and keeps tight hold of everything it licensed to you. That split decides what an Unreal studio can sell.
What you own
As between you and Epic, you own all rights in the products you develop under the agreement, other than rights in the licensed technology. Fab says the same of anything you make with its content.
Who may receive engine code
You may distribute engine code, modified or not, in source or object code only to a third party separately licensed by Epic for the same version. A buyer without an Unreal licence cannot take the engine half of your repository.
The generative AI bar
The EULA bars any use that results in the licensed technology becoming a training input to a generative AI program, and the content EULA bars putting NoAI content into datasets for such programs. Fab carries the same NoAI rule under a standard licence.
Source: What engine licences let leave a studio
Whether the code you wrote is protected at all is on is game code copyrighted.