diff --git a/Assets/ControllerMapper.asset b/Assets/ControllerMapper.asset index e3d0d54..23af3fe 100644 --- a/Assets/ControllerMapper.asset +++ b/Assets/ControllerMapper.asset @@ -17,9 +17,6 @@ MonoBehaviour: - name: Jump XboxButtons: 00000000 KeyboardKeys: - - name: Throw - XboxButtons: 01000000 - KeyboardKeys: - name: Sleep XboxButtons: 02000000 KeyboardKeys: @@ -48,6 +45,9 @@ MonoBehaviour: - name: LookBackward Axis: 07000000 KeyboardKeys: + - name: Throw + Axis: 09000000 + KeyboardKeys: ButtonStates: [] - name: Sleeping ButtonActions: diff --git a/Assets/Prefabs/Child.prefab b/Assets/Prefabs/Child.prefab index 1a95327..ba943e0 100644 --- a/Assets/Prefabs/Child.prefab +++ b/Assets/Prefabs/Child.prefab @@ -153,7 +153,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 567fe96dcacb08f4ab716a98ce99fc88, type: 3} m_Name: m_EditorClassIdentifier: - minAngleRange: 60 + minAngleRange: 10 --- !u!135 &13545904 SphereCollider: m_ObjectHideFlags: 1 @@ -214,6 +214,10 @@ Prefab: propertyPath: Speed value: 2 objectReference: {fileID: 0} + - target: {fileID: 0} + propertyPath: minAngleRange + value: 10 + objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 0} m_RootGameObject: {fileID: 190616} diff --git a/Assets/Scripts/AutoTarget.cs b/Assets/Scripts/AutoTarget.cs index 1dabcd8..178e3ad 100644 --- a/Assets/Scripts/AutoTarget.cs +++ b/Assets/Scripts/AutoTarget.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; public class AutoTarget : MonoBehaviour { private List targets; - public float minAngleRange = 60f; + public float minAngleRange = 20f; // Use this for initialization void Start () diff --git a/Assets/Scripts/ChildController.cs b/Assets/Scripts/ChildController.cs index bde9551..2f33e1d 100644 --- a/Assets/Scripts/ChildController.cs +++ b/Assets/Scripts/ChildController.cs @@ -88,6 +88,22 @@ public class ChildController : MonoBehaviour Mathf.Atan2(xLookingValue, zLookingValue) * Mathf.Rad2Deg -90, // -90 to correct forward facing angle... 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(); } } @@ -111,10 +127,6 @@ public class ChildController : MonoBehaviour _child.WakeUp(); InputManager.Instance.PushActiveContext("Awake", (int)PlayerNumber); } - - if (input.Actions.Contains("Throw")) { - _child.Throw(); - } } }