This started as a bug but then I found the source of it so I ended up fixing it myself. There is a related bug report but I figured posting it here also would be the right thing to do.
This is my first look into any playmaker code at all (I now have all of 10 mins experience with it!) so go easy on me.
The problem is that once you have used mouselook to rotate an object it will have its constraints frozen permanently.
It appears it was a piece of code that was only added because it was part of the unity code it was borrowed from. I think the code is necessary because there could be problems with other rotational effects causing the mouse control to appear buggy to the user. Exposing it as an option to the user to turn on and off is a good idea but only half the solution.
// Make the rigid body not change rotation
// TODO: Original Unity script had this. Expose as option?
if (go.rigidbody)
{
go.rigidbody.freezeRotation = true;
}
Two problems:
- Firstly it destroys user data as an artifact which is never good as a best practice. What if I set the freezing params in a certain way for a particular purpose?
- The second is that it leaves behind a residual and potentially unwanted after effect - that of a frozen object.
I would suggest that what should happen is:
- Rotation params are saved on entry
- Params are frozen if the users requires it (default:on)
- In all cases the rotation params are set back to the way they were before
Rather than just hand this over and expect someone else to do all the work I decided to have a crack at doing this myself.
Because the playmaker framework is so elegant it was trivial. (assuming I got it right)
I have attached my attempt at this code.
I hope this is correct.