slimecing

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 2e3dd30ffabf6e92e2d3eda51993ef6a6514ea11
parent 82764e7ac2ed9fecf1ceb019d52de776f7cf73af
Author: PlutoTank <qwolkensperg@gmail.com>
Date:   Fri, 17 Apr 2020 22:14:15 -0400

Mouse sword movement works better now. Deadzones on controller for swords

Diffstat:
MAssets/Scripts/Slimecing/InputSystem/SlimeControls.cs | 4++--
MAssets/Scripts/Slimecing/InputSystem/SlimeControls.inputactions | 4++--
MAssets/Scripts/Slimecing/Swords/Orbitals/OrbitalLogicScripts/InputOrbitalLogic.cs | 20+++++++++++++++-----
MAssets/Scripts/Slimecing/Swords/Orbitals/SOOrbitalStats/InputOrbitalStats.asset | 2+-
4 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/Assets/Scripts/Slimecing/InputSystem/SlimeControls.cs b/Assets/Scripts/Slimecing/InputSystem/SlimeControls.cs @@ -259,7 +259,7 @@ namespace Slimecing.InputSystem ""id"": ""ca69d397-54f1-4ea7-a580-7773a6e6f0a6"", ""path"": ""<Gamepad>/rightStick"", ""interactions"": """", - ""processors"": """", + ""processors"": ""StickDeadzone"", ""groups"": ""Gamepad"", ""action"": ""SwordMovement"", ""isComposite"": false, @@ -270,7 +270,7 @@ namespace Slimecing.InputSystem ""id"": ""1e69138a-f920-40c8-a4bc-4ff87648ceab"", ""path"": ""<Mouse>/position"", ""interactions"": """", - ""processors"": ""NormalizeVector2"", + ""processors"": """", ""groups"": ""Keyboard & Mouse"", ""action"": ""SwordMovement"", ""isComposite"": false, diff --git a/Assets/Scripts/Slimecing/InputSystem/SlimeControls.inputactions b/Assets/Scripts/Slimecing/InputSystem/SlimeControls.inputactions @@ -244,7 +244,7 @@ "id": "ca69d397-54f1-4ea7-a580-7773a6e6f0a6", "path": "<Gamepad>/rightStick", "interactions": "", - "processors": "", + "processors": "StickDeadzone", "groups": "Gamepad", "action": "SwordMovement", "isComposite": false, @@ -255,7 +255,7 @@ "id": "1e69138a-f920-40c8-a4bc-4ff87648ceab", "path": "<Mouse>/position", "interactions": "", - "processors": "NormalizeVector2", + "processors": "", "groups": "Keyboard & Mouse", "action": "SwordMovement", "isComposite": false, diff --git a/Assets/Scripts/Slimecing/Swords/Orbitals/OrbitalLogicScripts/InputOrbitalLogic.cs b/Assets/Scripts/Slimecing/Swords/Orbitals/OrbitalLogicScripts/InputOrbitalLogic.cs @@ -63,9 +63,7 @@ namespace Slimecing.Swords.Orbitals.OrbitalLogicScripts if (inputDir.Equals(Vector2.zero)) return; if (!(Mathf.Abs(inputDir.x) > 0.05f) && !(Mathf.Abs(inputDir.y) > 0.05f)) return; Vector3 center = owner.transform.position; - float pointX = inputDir.x; - float pointZ = inputDir.y; - float angle = Mathf.Atan2(pointX, pointZ) * Mathf.Rad2Deg; + float angle = Mathf.Atan2(inputDir.x, inputDir.y) * Mathf.Rad2Deg; var position = orbital.transform.position; float currentAngle = Mathf.Atan2(position.x - center.x,position.z - center.z) * Mathf.Rad2Deg; _finalSwordTarget = new Vector2(angle / 360f, currentAngle / 360f); @@ -74,10 +72,22 @@ namespace Slimecing.Swords.Orbitals.OrbitalLogicScripts public void TickUpdate(GameObject owner, GameObject orbital) { if (!_operatingOrbitalInputTrigger.currentTriggerState.Equals(TriggerState.Performed)) return; - if (_operatingOrbitalInputTrigger is TriggerInput orbitalTriggerInput) + if (!(_operatingOrbitalInputTrigger is TriggerInput orbitalTriggerInput)) return; + + if (orbitalTriggerInput.inputContext.control.device.name.Equals("Mouse")) { - GetInput(owner, orbital, orbitalTriggerInput.inputContext.ReadValue<Vector2>()); + if (UnityEngine.Camera.main != null) + { + Plane playerPlane = new Plane(Vector3.up, owner.transform.position); + Vector2 readInput = orbitalTriggerInput.inputContext.ReadValue<Vector2>(); + Ray ray = UnityEngine.Camera.main.ScreenPointToRay(readInput); + if (!playerPlane.Raycast(ray, out var distance)) return; + Vector3 targetPoint = ray.GetPoint(distance) - owner.transform.position; + GetInput(owner, orbital, new Vector2(targetPoint.x, targetPoint.z)); + return; + } } + GetInput(owner, orbital, orbitalTriggerInput.inputContext.ReadValue<Vector2>()); } } } \ No newline at end of file diff --git a/Assets/Scripts/Slimecing/Swords/Orbitals/SOOrbitalStats/InputOrbitalStats.asset b/Assets/Scripts/Slimecing/Swords/Orbitals/SOOrbitalStats/InputOrbitalStats.asset @@ -12,7 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 0a37f7d239ec14245970c23702857274, type: 3} m_Name: InputOrbitalStats m_EditorClassIdentifier: - orbitalSpeed: 10 + orbitalSpeed: 20 yOffset: 1 xAxis: 2.5 yAxis: 2.5