Reset HingeJoints in OnEpisodeBegin function

Hello friends,

I am want to use ML Agents for a robot with HingeJoints, and whenever the function OnEpisodeBegin is execute, i want to initialize all my hingejoints angles, at the same angle like in starting the simulation.
When i am trying that in the function, it is not work and the angles from the previous episode stays for the next.

Someone know what should i do ?

This is the code in the OnEpisodeBegin.

for (int i = 0; i < Joints.Length; i++)
{
var tempSpring = Joints*.spring;*
tempSpring.targetPosition = 0;
Joints*.spring = tempSpring;*
}
Thanks

Hi @OrSimhon ,
The agents don’t get destroyed on new episodes. The same agent instance persists unless you destroy it manually.

For the hinge joint issue, please see this other forum post about setting the angle: HingeJoint and setting angle.