Praise be to Allah.
If the aim is to obey Allah, to follow the example of the Messenger of Allah (peace and blessings of Allah be upon him), to have a righteous child, to keep oneself chaste and to protect one’s private parts, eyes and heart, etc., then it is one of the actions of the Hereafter and a person will be rewarded for it. If there is no such intention, then it is permissible and is one of the actions of this world which is solely for enjoyment. It will not be rewarded, but there is no sin involved.
And Allah knows best.