Is it legal to build/sell an engine on top of UE4?

like if you’re making one of those rpg makers?
I suppose if your customers are fine paying both you and epic it might be alright. though inconvenient.
definitely a grey area though. probably should use something else if you can’t get a clear answer. maybe godot?