From e6892214ea9c36d185d2cb7d5793e6e2e4c45ca3 Mon Sep 17 00:00:00 2001 From: Xaver Drabik Date: Wed, 18 Dec 2024 15:19:25 +0100 Subject: [PATCH] dash in movement dir --- .../Scripts/Creatures/Player/PlayerMove.cs | 13 +++--- twinStickCrawler/Assets/Scripts/Enemy.meta | 8 ---- .../Assets/Scripts/Enemy/EnemyMove.cs | 22 --------- .../Assets/Scripts/Enemy/EnemyMove.cs.meta | 2 - twinStickCrawler/Assets/Scripts/Player.meta | 8 ---- .../Assets/Scripts/Player/CameraMove.cs | 27 ----------- .../Assets/Scripts/Player/CameraMove.cs.meta | 2 - .../Assets/Scripts/Player/PlayerMove.cs | 46 ------------------- .../Assets/Scripts/Player/PlayerMove.cs.meta | 2 - 9 files changed, 6 insertions(+), 124 deletions(-) delete mode 100644 twinStickCrawler/Assets/Scripts/Enemy.meta delete mode 100644 twinStickCrawler/Assets/Scripts/Enemy/EnemyMove.cs delete mode 100644 twinStickCrawler/Assets/Scripts/Enemy/EnemyMove.cs.meta delete mode 100644 twinStickCrawler/Assets/Scripts/Player.meta delete mode 100644 twinStickCrawler/Assets/Scripts/Player/CameraMove.cs delete mode 100644 twinStickCrawler/Assets/Scripts/Player/CameraMove.cs.meta delete mode 100644 twinStickCrawler/Assets/Scripts/Player/PlayerMove.cs delete mode 100644 twinStickCrawler/Assets/Scripts/Player/PlayerMove.cs.meta diff --git a/twinStickCrawler/Assets/Scripts/Creatures/Player/PlayerMove.cs b/twinStickCrawler/Assets/Scripts/Creatures/Player/PlayerMove.cs index c9111af..8aff06e 100644 --- a/twinStickCrawler/Assets/Scripts/Creatures/Player/PlayerMove.cs +++ b/twinStickCrawler/Assets/Scripts/Creatures/Player/PlayerMove.cs @@ -45,8 +45,7 @@ void Start() _camera = _cameraGameObject.GetComponent(); _controller = GetComponent(); } - - // Update is called once per frame + void Update() { Vector3 input = new Vector3(_inputManager.moveInput.x, 0f , _inputManager.moveInput.y); @@ -71,6 +70,7 @@ void ApplyMovement(Vector3 moveDir, Vector3 lookTarget) } } + Vector3 _lastMoveDir = Vector3.zero; Vector3 MoveDir(Vector3 input) { if (_dashing) @@ -80,7 +80,8 @@ Vector3 MoveDir(Vector3 input) Quaternion camRotation = Quaternion.Euler(0f, _cameraGameObject.transform.rotation.eulerAngles.y, 0f); input = camRotation * input; - + + _lastMoveDir = input; return input; } @@ -114,9 +115,7 @@ Vector3 LookTarget() Vector3 aimTargetPosition = hit.collider.transform.position; float distanceToTarget = Vector3.Distance(transform.position, aimTargetPosition); - float assistStrength = distanceToTarget <= minAimDistance - ? 1f // Full strength if within minAimDistance - : Mathf.Clamp01(1 - (distanceToTarget - minAimDistance) / (maxAimDistance - minAimDistance)); + float assistStrength = Mathf.Clamp(1-(distanceToTarget - minAimDistance) / (maxAimDistance - minAimDistance), 0f, .6f); targetPoint = Vector3.Lerp(targetPoint, aimTargetPosition, assistStrength); @@ -148,7 +147,7 @@ private IEnumerator DashCoroutine() float startTime = Time.time; while(Time.time < startTime + dashTime) { - _controller.Move(transform.forward * dashSpeed * Time.deltaTime); + _controller.Move(_lastMoveDir * dashSpeed * Time.deltaTime); yield return null; } _dashing = false; diff --git a/twinStickCrawler/Assets/Scripts/Enemy.meta b/twinStickCrawler/Assets/Scripts/Enemy.meta deleted file mode 100644 index 121b36b..0000000 --- a/twinStickCrawler/Assets/Scripts/Enemy.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 2c1b0f7967bd84431ba19240b39e2f1b -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/twinStickCrawler/Assets/Scripts/Enemy/EnemyMove.cs b/twinStickCrawler/Assets/Scripts/Enemy/EnemyMove.cs deleted file mode 100644 index da574ed..0000000 --- a/twinStickCrawler/Assets/Scripts/Enemy/EnemyMove.cs +++ /dev/null @@ -1,22 +0,0 @@ -using UnityEngine; -using UnityEngine.AI; - -public class EnemyMove : MonoBehaviour -{ - public GameObject player; - - private NavMeshAgent _meshAgent; - // Start is called once before the first execution of Update after the MonoBehaviour is created - void Start() - { - _meshAgent = GetComponent(); - } - - // Update is called once per frame - void Update() - { - Vector3 playerPos = player.transform.position; - - _meshAgent.SetDestination(playerPos); - } -} \ No newline at end of file diff --git a/twinStickCrawler/Assets/Scripts/Enemy/EnemyMove.cs.meta b/twinStickCrawler/Assets/Scripts/Enemy/EnemyMove.cs.meta deleted file mode 100644 index d9d4373..0000000 --- a/twinStickCrawler/Assets/Scripts/Enemy/EnemyMove.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: f4f29a7caf57449789b9106e40d9bb19 \ No newline at end of file diff --git a/twinStickCrawler/Assets/Scripts/Player.meta b/twinStickCrawler/Assets/Scripts/Player.meta deleted file mode 100644 index 08a86b3..0000000 --- a/twinStickCrawler/Assets/Scripts/Player.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: f06a034470c5546838be0794f5bb513a -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/twinStickCrawler/Assets/Scripts/Player/CameraMove.cs b/twinStickCrawler/Assets/Scripts/Player/CameraMove.cs deleted file mode 100644 index 1d84bdf..0000000 --- a/twinStickCrawler/Assets/Scripts/Player/CameraMove.cs +++ /dev/null @@ -1,27 +0,0 @@ -using UnityEngine; - -public class CameraMove : MonoBehaviour -{ - public Vector3 camOffset; - - [SerializeField] private GameObject player; - - // Start is called once before the first execution of Update after the MonoBehaviour is created - void Start() - { - - } - - // Update is called once per frame - void LateUpdate() - { - camOffset.z = camOffset.x; - Vector3 desiredCamPos = player.transform.position; - desiredCamPos.x += camOffset.x; - desiredCamPos.y += camOffset.y; - desiredCamPos.z += camOffset.z; - - transform.position = desiredCamPos; - transform.LookAt(player.transform); - } -} diff --git a/twinStickCrawler/Assets/Scripts/Player/CameraMove.cs.meta b/twinStickCrawler/Assets/Scripts/Player/CameraMove.cs.meta deleted file mode 100644 index 9fa274e..0000000 --- a/twinStickCrawler/Assets/Scripts/Player/CameraMove.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 05236f4b383a944c19e8c2cdfb026e66 \ No newline at end of file diff --git a/twinStickCrawler/Assets/Scripts/Player/PlayerMove.cs b/twinStickCrawler/Assets/Scripts/Player/PlayerMove.cs deleted file mode 100644 index 0ecf37e..0000000 --- a/twinStickCrawler/Assets/Scripts/Player/PlayerMove.cs +++ /dev/null @@ -1,46 +0,0 @@ -using UnityEngine; -using UnityEngine.InputSystem; - -public class PlayerMove : MonoBehaviour -{ - [Range(0f, 10f)] - public float moveSpeed = 5f; - - [SerializeField] - private InputManager _inputManager; - [SerializeField] - private GameObject _camera; - - private CharacterController _controller; - - // Start is called once before the first execution of Update after the MonoBehaviour is created - void Start() - { - _controller = GetComponent(); - } - - // Update is called once per frame - void Update() - { - Vector3 input = new Vector3(_inputManager.moveInput.x, 0f , _inputManager.moveInput.y); - - Vector3 moveDir = Vector3.zero; - moveDir += MoveDir(input); - moveDir += Gravity(); - - _controller.Move(moveSpeed * moveDir * Time.deltaTime); - } - - Vector3 MoveDir(Vector3 input) - { - Quaternion camRotation = Quaternion.Euler(0f, _camera.transform.rotation.eulerAngles.y, 0f); - input = camRotation * input; - - return input; - } - - Vector3 Gravity() - { - return Physics.gravity; - } -} diff --git a/twinStickCrawler/Assets/Scripts/Player/PlayerMove.cs.meta b/twinStickCrawler/Assets/Scripts/Player/PlayerMove.cs.meta deleted file mode 100644 index 43aef33..0000000 --- a/twinStickCrawler/Assets/Scripts/Player/PlayerMove.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 726bb6542b066483c9e1c5ab04620ffe \ No newline at end of file