You are not permitted to download, save or email this image. Visit image gallery to purchase the image.
Education Minister Chris Hipkins' announcement of the code follows the death of Christchurch student Mason Pendrous, whose body was discovered after lying for a month in student accommodation.
Breaches resulting in serious harm or death to students - including those in accommodation outsourced to third-party providers - will be punishable by a $100,000 fine.
Former warden Ashley Day, who raised concerns about declining numbers of RAs at Otago last month, said he wanted to see a compulsory ratio of about 1:20 of RAs to students in every hall.
''I hope the minister recognises that so there is a stipulation of a minimum number of students per RA, a good, healthy ratio.''
A temporary code will be introduced in the new year and a permanent one set up by 2021.
In the five colleges Mr Day had overseen, RAs were the ''eyes and ears'' of the establishment and had met the administration each week to discuss troubled students.
The university has said RA numbers at present range from 1:18 students, to 1:33, depending on the size of the halls.
However, a university spokeswoman said Otago also had ''senior live-in pastoral support'' including a leader for each college and between one and five deputy live-in staff or assistants, and the number of total pastoral staff was already better than 1:20 for all colleges.
University halls - and those formally affiliated to the university - cannot be operated by for-profit commercial providers.
Otago Polytechnic's Te Pa Taiura Student Village is run by Campus Living Villages, the same organisation in charge of Sonoda, where the body of Mr Pendrous was found.
Deputy chief executive and operating officer Phil Cullen said greater face-to-face contact had already been put in place, as had electronic access monitoring, to alert staff to a lack of resident movement.
The number of permanent staff in any hall or hostel also had to be taken into account if any compulsory ratio was introduced.
In 2018, former RAs at the university criticised conditions and lack of training for what they faced in their role.
However, Mr Day, who retired in 2016, said he thought staff numbers was the important thing to enshrine in the legislation.
Excellent training was already provided to RAs at the University of Otago, including two weeks of training at the beginning of the year and further opportunities to train with colleagues and colleges throughout the year.
University of Otago head of campus and collegiate life services James Lindsay said in 2018 RAs were given basic training in first aid, how to recognise symptoms of mental health issues, and could handle the first contact reporting of an alleged sexual misconduct case.
Prof Hayne said yesterday Otago was constantly refining its approach to pastoral care, and she had seen nothing in the proposals that would suggest the need for a change of approach.