From 15d177695783570dbf0d0d6bde59dcc9fbe207b9 Mon Sep 17 00:00:00 2001 From: jparent Date: Sun, 23 Aug 2015 09:46:46 -0400 Subject: [PATCH 1/3] change controls to throw with Right Trigger change the ControllerMapper so that throwing a pillow is now done with the Right Trigger insead of B button. --- Assets/ControllerMapper.asset | 6 +++--- Assets/Scripts/ChildController.cs | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) 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/Scripts/ChildController.cs b/Assets/Scripts/ChildController.cs index bde9551..324ff84 100644 --- a/Assets/Scripts/ChildController.cs +++ b/Assets/Scripts/ChildController.cs @@ -88,6 +88,10 @@ public class ChildController : MonoBehaviour Mathf.Atan2(xLookingValue, zLookingValue) * Mathf.Rad2Deg -90, // -90 to correct forward facing angle... transform.eulerAngles.z); } + } + + if (input.Ranges.ContainsKey("Throw")) { + _child.Throw(); } } @@ -111,10 +115,6 @@ public class ChildController : MonoBehaviour _child.WakeUp(); InputManager.Instance.PushActiveContext("Awake", (int)PlayerNumber); } - - if (input.Actions.Contains("Throw")) { - _child.Throw(); - } } } From 91cf1734ba185817ba65f9e5cac85ded5f323463 Mon Sep 17 00:00:00 2001 From: jparent Date: Sun, 23 Aug 2015 10:18:44 -0400 Subject: [PATCH 2/3] reduce minimum angle range for auto-target to 10 --- Assets/Prefabs/Child.prefab | 6 +++++- Assets/Scripts/AutoTarget.cs | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Assets/Prefabs/Child.prefab b/Assets/Prefabs/Child.prefab index d3d5e2a..d301993 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 () From 4568e778717f4f3020082dfff5e4ff0bbf44b7ab Mon Sep 17 00:00:00 2001 From: jparent Date: Sun, 23 Aug 2015 10:21:06 -0400 Subject: [PATCH 3/3] 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();