Topic: [Code] Allowing character to turnaround.
It's not very complex but I thought I would explain it anyways for anyone looking to have a feature like this. Or maybe it can come in the next update :]
Step 1) In GlobalInfo.c in the CharacterRotationsOptions add:
public bool turnAround = false;
Step 2) In ControlsScript.c in the function TestCharacterRotation() add the following:
if (!UFE.config.characterRotationOptions.turnAround) {
//MMINDS Code
} else if (UFE.config.characterRotationOptions.turnAround) {
if (mirror == -1 && myPhysicsScript.moveDirection == -1) {
mirror = 1;
standardYRotation = 360 - standardYRotation;
if (UFE.config.characterRotationOptions.autoMirror) {
if (myInfo.animationType == AnimationType.Legacy) {
character.transform.localScale = new Vector3 (-character.transform.localScale.x, character.transform.localScale.y, character.transform.localScale.z);
} else {
myHitBoxesScript.invertHitBoxes (true);
myMoveSetScript.SetMecanimMirror (true);
}
}
} else if (mirror == 1 && myPhysicsScript.moveDirection == 1) {
mirror = -1;
standardYRotation = 360 - standardYRotation;
if (UFE.config.characterRotationOptions.autoMirror) {
if (myInfo.animationType == AnimationType.Legacy) {
character.transform.localScale = new Vector3 (-character.transform.localScale.x, character.transform.localScale.y, character.transform.localScale.z);
} else {
myHitBoxesScript.invertHitBoxes (false);
myMoveSetScript.SetMecanimMirror (false);
}
}
}
}
character.transform.rotation = Quaternion.Slerp(character.transform.rotation, Quaternion.AngleAxis(standardYRotation, Vector3.up), Time.deltaTime * rotationSpeed);
Step 3) Make moveDirection public in the physics script
Step 4) Add GUI to GlobalEditorWindow.c to toggle from the menu (for convenience). I just added this around line 400.
globalInfo.characterRotationOptions.turnAround = EditorGUILayout.Toggle("Turn Around", globalInfo.characterRotationOptions.turnAround);