projetrunandgun/Assets/Scripts/Cores/RegularProjectile.cs

29 lines
626 B
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RegularProjectile : MonoBehaviour
{
private const float LIVE_TIME = 2f;
private float _speed;
private void Start()
{
Destroy(gameObject, LIVE_TIME);
}
private void Update()
{
transform.position += transform.right * (_speed * Time.deltaTime);
}
public void SetSpeed(float speed) => _speed = speed;
private void OnTriggerEnter2D(Collider2D other)
{
if(other.gameObject != PlayerMain.Instance.gameObject)
Destroy(gameObject);
}
}