using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; public class MinionThrower : MonoBehaviour { public GameObject placeholderMinionPrefab; public GameObject aimArrow; bool isInThrowMode; Vector2 throwDirection = Vector2.right; MinionBar minionBar; void Awake() { minionBar = FindObjectOfType(); } public void ToggleThrowMode(InputAction.CallbackContext context) { if(context.performed) { isInThrowMode = true; } else if(context.canceled) { PerformThrow(); isInThrowMode = false; } } public void AimThrow(InputAction.CallbackContext context) { throwDirection = context.ReadValue().normalized; } void PerformThrow() { if(!isInThrowMode) { return; } Object currentMinion = minionBar.GetCurrentMinion(); GameObject newMinion = Instantiate(placeholderMinionPrefab, transform.position + new Vector3(throwDirection.x, throwDirection.y, 0f) * 1f, Quaternion.identity); } }