The script will indeed snap the BodyAngle_Snapped parameter to 45 degrees - I was under the impression you wanted access to both a "snapped" value and a regular one.
As the script is isolated from AC, it can always be amended to suit your needs, but I don't follow what you mean. If you can give a clear example - ideally with images that demonstrate - of what it is exactly you want, I can try to help further.
When character starts to rotate parameter is changing value (it doesnt snap), when rotation ends at
some value, it snaps to the nearest 45 angle.
But if it would be possible to make this snap not be instantenious, but to have changing value when it is going toward nearest 45 angle. So when rotation ends before or after nearest 45 angle parameter is still continuosly changing value until it reaches nearest 45 angle. In reality character has ended rotation at some angle that is not at 45, but parameter is no longer connected to rotation but is changing value to end at 45 angle.
I noticed some problem that has nothing to do with your script.
Turn float is acting as expected when character starts to move. When rotation starts, turn float is 1 or -1 when character starts to move it becomes 0. But if character has to do pathfinding , for example has to rotate to avoid hole, during rotation Turn float remains to be 0.
As I said earlier, the turn float is only set when the character is idle (and so turning on the spot). If you want a "true" turn speed, you can read the character script's GetTurnFloat method and set it to a separate float parameter.
This is what the script above also does when setting the value of "isTurningRight".
A lot more tricky, but may be possible via an external script.
Basically you can try setting the Player component's "Motion control" to "Manual" when you don't want him to move, and back to "Automatic" when you're ready to have him continue moving:
I was doing more testing of a script and i noticed that from time to time character starts to rotate in opposite direction slightly, than it starts to rotate where it should.
It is like it is doing angle correction from the start but in opposite direction of intendent rotation.
I managed to get parameter in animator for turn float.
I am now trying to use character.motionControl = MotionControl.Manual; to stop motion of character when i want. But it seems that this stops character completely.
What i need is that character is allowed to rotate and translation is what i want to control. Is this possible?
Comments
As the script is isolated from AC, it can always be amended to suit your needs, but I don't follow what you mean. If you can give a clear example - ideally with images that demonstrate - of what it is exactly you want, I can try to help further.
Try this:
http://pasteall.org/816471/csharp
A bit rough around the edges, and the "Correction speed" might need tweaking, but is that more like it?
This is what the script above also does when setting the value of "isTurningRight".
Basically you can try setting the Player component's "Motion control" to "Manual" when you don't want him to move, and back to "Automatic" when you're ready to have him continue moving:
character.motionControl = MotionControl.Manual;
https://docs.unity3d.com/ScriptReference/Animator.SetFloat.html
https://docs.unity3d.com/ScriptReference/Animator.GetFloat.html