From 4568e778717f4f3020082dfff5e4ff0bbf44b7ab Mon Sep 17 00:00:00 2001 From: jparent Date: Sun, 23 Aug 2015 10:21:06 -0400 Subject: [PATCH] fix the auto-target to lock only when looking else, look in the direction we're going --- Assets/Scripts/ChildController.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Assets/Scripts/ChildController.cs b/Assets/Scripts/ChildController.cs index 324ff84..2f33e1d 100644 --- a/Assets/Scripts/ChildController.cs +++ b/Assets/Scripts/ChildController.cs @@ -89,6 +89,18 @@ public class ChildController : MonoBehaviour transform.eulerAngles.z); } } + else { + _child.target = null; // no auto targeting when not actively pressing the joystick in a direction + + // if player is not look with the right joystick, then face the direction we're going + // if left joystick is used, else we don't change the facing direction + if (xValue != 0 || zValue!= 0) { + transform.eulerAngles = new Vector3( + transform.eulerAngles.x, + Mathf.Atan2(xValue, zValue) * Mathf.Rad2Deg - 90, + transform.eulerAngles.z); + } + } if (input.Ranges.ContainsKey("Throw")) { _child.Throw();