Space-Smash-Out/Assets/Scripts/CollectibleWeapon.cs

35 lines
623 B
C#

using System.Collections;
using System.Collections.Generic;
using FORGE3D;
using PrimeTween;
using UnityEngine;
using UnityEngine.Animations;
public class CollectibleWeapon : MonoBehaviour
{
public WeaponEffect weapon;
public bool spin;
public float spinSpeed = 1f;
public GameObject model;
void Update()
{
model.transform.localRotation *= Quaternion.Euler(0, 0, spinSpeed);
}
private void OnTriggerEnter(Collider other)
{
if (other.tag != "Ship")
{
return;
}
if (!other.gameObject.TryGetComponent(out Ship ship))
{
return;
}
ship.EquipWeapon(weapon);
gameObject.SetActive(false);
}
}