private void Facing() { if (rpgCharacterController.canFace) { if (HasFacingInput()) { if (inputFace) { // Get world position from mouse position on screen and convert to direction from character. Plane playerPlane = new Plane(Vector3.up, transform.position); Ray ray = Camera.main.ScreenPointToRay(Mouse.current.position.ReadValue()); float hitdist = 0.0f; if (playerPlane.Raycast(ray, out hitdist)) { Vector3 targetPoint = ray.GetPoint(hitdist); Vector3 lookTarget = new Vector3(targetPoint.x - transform.position.x, transform.position.z - targetPoint.z, 0); rpgCharacterController.SetFaceInput(lookTarget); } } else { rpgCharacterController.SetFaceInput(new Vector3(inputFacing.x, inputFacing.y, 0)); } if (rpgCharacterController.CanStartAction("Face")) { rpgCharacterController.StartAction("Face"); } } else { if (rpgCharacterController.CanEndAction("Face")) { rpgCharacterController.EndAction("Face"); } } } }