27 lines
531 B
C#
27 lines
531 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
public class BulletMovement : MonoBehaviour
|
|
{
|
|
public float moveSpeed = 10;
|
|
public float lifeTime = 2;
|
|
private float _currentTime = 0;
|
|
|
|
private void OnEnable()
|
|
{
|
|
_currentTime = lifeTime;
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
transform.Translate(Vector2.up * (Time.deltaTime * moveSpeed));
|
|
_currentTime -= Time.deltaTime;
|
|
if (_currentTime <= 0)
|
|
{
|
|
gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
}
|