using System.Collections; using System.Collections.Generic; using UnityEngine; namespace Saltosion.OneWeapon { public class Gun : MonoBehaviour { public Bullet Bullet; private bool IsHeld = false; void Start() { } void Update() { } void OnTriggerEnter2D(Collider2D collider) { if (IsHeld) { return; } Player Player = collider.GetComponent(); if (Player != null) { IsHeld = true; Player.SetGun(this); Destroy(GetComponent()); } } public void Shoot(Vector2 position, Vector2 direction, float rotation) { if (Bullet == null) { Debug.LogError("THERE IS NO BULLET"); } else { Bullet ShotBullet = Instantiate(Bullet, position, new Quaternion()); ShotBullet.Direction = direction.normalized; ShotBullet.InitialRotation = rotation; } } } }