You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
RatAttack2D/Assets/Scripts/Weapons.cs

39 lines
747 B

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class Weapons : MonoBehaviour
{
private Inputs Input;
private InputAction Shoot;
private void Awake()
{
Input = new Inputs();
}
private void OnEnable()
{
Shoot = Input.Movement.attack;
Shoot.Enable();
}
private void OnDisable()
{
Shoot.Disable();
}
private void Update()
{
if(Shoot.IsPressed())
{
shoot();
}
}
private void shoot()
{
if(transform.childCount > 0)
{
Transform gun = transform.GetChild(0);
gun.GetComponent<Weapon>().shoot();
}
}
}