diff --git a/Assets/InputSystem_Actions.inputactions b/Assets/InputSystem_Actions.inputactions index 3c88953..aa0e1f3 100644 --- a/Assets/InputSystem_Actions.inputactions +++ b/Assets/InputSystem_Actions.inputactions @@ -41,7 +41,7 @@ "path": "/leftStick", "interactions": "", "processors": "", - "groups": ";Gamepad", + "groups": "Gamepad", "action": "Move", "isComposite": false, "isPartOfComposite": false @@ -214,7 +214,7 @@ { "name": "", "id": "b3f66d0b-7751-423f-908b-a11c5bd95930", - "path": "/buttonNorth", + "path": "/buttonEast", "interactions": "", "processors": "", "groups": "Gamepad", @@ -285,7 +285,7 @@ "path": "/buttonEast", "interactions": "", "processors": "", - "groups": ";Gamepad", + "groups": "Gamepad", "action": "Interact", "isComposite": false, "isPartOfComposite": false @@ -313,6 +313,15 @@ "processors": "", "interactions": "", "initialStateCheck": false + }, + { + "name": "Interact", + "type": "Button", + "id": "c8a2c7b1-7c4b-4b6c-9c67-5f4a2a6f8c1c", + "expectedControlType": "", + "processors": "", + "interactions": "", + "initialStateCheck": false } ], "bindings": [ @@ -337,6 +346,17 @@ "action": "Jump", "isComposite": false, "isPartOfComposite": false + }, + { + "name": "", + "id": "c3c7b8ad-6b3b-4a4c-9b0b-1c2f7e9a4d5e", + "path": "/buttonEast", + "interactions": "", + "processors": "", + "groups": "Gamepad", + "action": "Interact", + "isComposite": false, + "isPartOfComposite": false } ] }, @@ -361,6 +381,15 @@ "processors": "", "interactions": "", "initialStateCheck": false + }, + { + "name": "Interact", + "type": "Button", + "id": "e2e9b2d1-8f44-4a8b-b5a0-4f1d6a7c9b2a", + "expectedControlType": "", + "processors": "", + "interactions": "", + "initialStateCheck": false } ], "bindings": [ @@ -385,6 +414,17 @@ "action": "Jump", "isComposite": false, "isPartOfComposite": false + }, + { + "name": "", + "id": "b1f0f4f1-2d7a-4c1e-9c6a-8e5b7c9d1a3f", + "path": "/buttonEast", + "interactions": "", + "processors": "", + "groups": "Gamepad", + "action": "Interact", + "isComposite": false, + "isPartOfComposite": false } ] }, @@ -501,7 +541,7 @@ "path": "/leftStick/up", "interactions": "", "processors": "", - "groups": ";Gamepad", + "groups": "Gamepad", "action": "Navigate", "isComposite": false, "isPartOfComposite": true @@ -512,7 +552,7 @@ "path": "/rightStick/up", "interactions": "", "processors": "", - "groups": ";Gamepad", + "groups": "Gamepad", "action": "Navigate", "isComposite": false, "isPartOfComposite": true @@ -523,7 +563,7 @@ "path": "/leftStick/down", "interactions": "", "processors": "", - "groups": ";Gamepad", + "groups": "Gamepad", "action": "Navigate", "isComposite": false, "isPartOfComposite": true @@ -534,7 +574,7 @@ "path": "/rightStick/down", "interactions": "", "processors": "", - "groups": ";Gamepad", + "groups": "Gamepad", "action": "Navigate", "isComposite": false, "isPartOfComposite": true @@ -545,7 +585,7 @@ "path": "/leftStick/left", "interactions": "", "processors": "", - "groups": ";Gamepad", + "groups": "Gamepad", "action": "Navigate", "isComposite": false, "isPartOfComposite": true @@ -556,7 +596,7 @@ "path": "/rightStick/left", "interactions": "", "processors": "", - "groups": ";Gamepad", + "groups": "Gamepad", "action": "Navigate", "isComposite": false, "isPartOfComposite": true @@ -567,7 +607,7 @@ "path": "/leftStick/right", "interactions": "", "processors": "", - "groups": ";Gamepad", + "groups": "Gamepad", "action": "Navigate", "isComposite": false, "isPartOfComposite": true @@ -578,7 +618,7 @@ "path": "/rightStick/right", "interactions": "", "processors": "", - "groups": ";Gamepad", + "groups": "Gamepad", "action": "Navigate", "isComposite": false, "isPartOfComposite": true @@ -589,7 +629,7 @@ "path": "/dpad", "interactions": "", "processors": "", - "groups": ";Gamepad", + "groups": "Gamepad", "action": "Navigate", "isComposite": false, "isPartOfComposite": false @@ -967,4 +1007,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/Assets/Scenes/Experiment.unity b/Assets/Scenes/Experiment.unity index 1fb2b9f..5960e50 100644 --- a/Assets/Scenes/Experiment.unity +++ b/Assets/Scenes/Experiment.unity @@ -2843,6 +2843,7 @@ MonoBehaviour: spawnInterval: 3 maxAlive: 1 spawnOnStart: 1 + repeatSpawns: 0 --- !u!1660057539 &9223372036854775807 SceneRoots: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/PlayerPickupController.cs b/Assets/Scripts/PlayerPickupController.cs index e960e34..539c120 100644 --- a/Assets/Scripts/PlayerPickupController.cs +++ b/Assets/Scripts/PlayerPickupController.cs @@ -83,31 +83,33 @@ public class PlayerPickupController : MonoBehaviour Debug.Log(colliders.Length + " colliders found in range"); foreach (var col in colliders) { - if (col.CompareTag("Interactable")) + if (!col.TryGetComponent(out var trick) && !col.CompareTag("Interactable")) { - heldObject = col.gameObject; - - // Parent the object to the HoldPoint and reset its local position - heldObject.transform.SetParent(holdPoint); - heldObject.transform.localPosition = Vector3.zero; - heldObject.transform.localRotation = Quaternion.identity; - - // Disable physics so it doesn't fall or collide with the player - if (heldObject.TryGetComponent(out Rigidbody2D rb)) - { - rb.bodyType = RigidbodyType2D.Kinematic; - rb.gravityScale = 0; - rb.mass = 0; - } - - if (heldObject.TryGetComponent(out var trick)) - { - trick.SetCarried(true); - } - - if (col != null) col.enabled = false; - break; + continue; } + + heldObject = col.gameObject; + + // Parent the object to the HoldPoint and reset its local position + heldObject.transform.SetParent(holdPoint); + heldObject.transform.localPosition = Vector3.zero; + heldObject.transform.localRotation = Quaternion.identity; + + // Disable physics so it doesn't fall or collide with the player + if (heldObject.TryGetComponent(out Rigidbody2D rb)) + { + rb.bodyType = RigidbodyType2D.Kinematic; + rb.gravityScale = 0; + rb.mass = 0; + } + + if (trick != null) + { + trick.SetCarried(true); + } + + if (col != null) col.enabled = false; + break; } } diff --git a/Assets/Scripts/Spawner.cs b/Assets/Scripts/Spawner.cs index 2559848..051a10b 100644 --- a/Assets/Scripts/Spawner.cs +++ b/Assets/Scripts/Spawner.cs @@ -10,6 +10,7 @@ public class Spawner : MonoBehaviour public float spawnInterval = 1f; [SerializeField] private int maxAlive = 0; [SerializeField] private bool spawnOnStart = true; + [SerializeField] private bool repeatSpawns = true; private readonly List spawned = new List(); @@ -23,8 +24,11 @@ public class Spawner : MonoBehaviour void Start() { - // Start the spawning process using a Coroutine - StartCoroutine(SpawnRoutine()); + if (repeatSpawns) + { + // Start the spawning process using a Coroutine + StartCoroutine(SpawnRoutine()); + } } private IEnumerator SpawnRoutine() diff --git a/Assets/Scripts/TrickController.cs b/Assets/Scripts/TrickController.cs index c27237f..aeff187 100644 --- a/Assets/Scripts/TrickController.cs +++ b/Assets/Scripts/TrickController.cs @@ -10,6 +10,7 @@ public class TrickController : MonoBehaviour [SerializeField] private float targetRefreshInterval = 0.4f; [SerializeField] private float consumeDistance = 0.35f; [SerializeField] private float wanderInterval = 1.2f; + [SerializeField] private float consumeCooldown = 1.5f; [SerializeField] private TrickController trickPrefab; private Rigidbody2D body; @@ -18,6 +19,7 @@ public class TrickController : MonoBehaviour private Vector2 wanderDirection; private float nextWanderTime; private bool isCarried; + private float nextConsumeTime; private void Awake() { @@ -136,6 +138,11 @@ public class TrickController : MonoBehaviour return; } + if (Time.time < nextConsumeTime) + { + return; + } + var hits = Physics2D.OverlapCircleAll(transform.position, consumeDistance); for (var i = 0; i < hits.Length; i++) { @@ -152,6 +159,7 @@ public class TrickController : MonoBehaviour target = null; } SpawnTrick(spawnPosition); + nextConsumeTime = Time.time + consumeCooldown; break; } }