Not sure if it even has anything to do with this but if you're talking about a "wet dream". It happens to me about once a year and I do feel guilty about it afterwards but it wasn't an act of the will, nor did I have control over it.
There has been some occasions where I'm half-conscious/half-asleep and I'll have semi-deliberate carnal thoughts, when I'm fully coherent I don't have them or want them but when I'm half-asleep then sometimes they come up and then when I realize what's happening I pray and fight it off. I'm not 100% sure on cases like that, might be venial sin for cases like that, I guess it could be mortal sin if after you were conscious and aware of what was happening and you took delight and thought about it more without fighting it off.