Is there a way to set up your player character to turn following the mouse pointer while its standing still...
I was planning on using Partel's FINALIK to use the LookatIK to have my character's head and eye's follow the mouse but I was thinking wouldn't it be cool if the character turned 90 degrees after my mouse crossed 90 degrees, that way the character is always facing towards the direction the player wants to go... I thought it would add a cool factor to the player experience...
Comments
Player player = GameObject.FindWithTag (Tags.player).GetComponent <Player>();
if (player.charState == CharState.Idle)
{
player.SetLookDirection (lookVector, true);
}
Also be sure to include the "AC" namespace in your script.
Thanks again...
Vector3 direction = lookAt.solver.IKPosition - character.position; Vector3 directionLocal = character.InverseTransformDirection(direction); float angle = Mathf.Atan2(directionLocal.x, directionLocal.z) * Mathf.RadToDeg; if (angle >= 45 && angle < 180) animator.CrossFade("TurnLeft", transitionDuration); if (angle >= 180 && angle < 315) animator.CrossFade("TurnRight", transitionDuration);
Question is would I put this in the character controller script in AC?Sorry to be such a goof... I'm a modeler/animator/story teller, not a coder, any help would be greatly appreciated.
Thanks again Chris!
I'd change the TurnLeft / TurnRight parameter names to something like LookLeft / LookRight, and just update your Mecanim FSM to accomodate it. I'm not sure where this InverseTransformDirection function comes from, but I'm assuming that's part of the LookAtIK asset.