Throw start

This commit is contained in:
Yann Dupont 01 2022-04-02 01:34:50 -04:00
parent 2657ca3d20
commit c428a0e96f
2 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,41 @@
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<MinionBar>();
}
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<Vector2>().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);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 56c3e06ea5db48a40a7f55e72291cb0d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: