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