28 lines
661 B
C#
28 lines
661 B
C#
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
public class SukunaProjectile : MonoBehaviour
|
||
|
|
{
|
||
|
|
[Header("Movement")]
|
||
|
|
public float speed = 50f;
|
||
|
|
public float lifetime = 3f;
|
||
|
|
|
||
|
|
private Vector3 moveDirection;
|
||
|
|
|
||
|
|
public void SetDirection(Vector3 direction)
|
||
|
|
{
|
||
|
|
// Nhận hướng bay từ Player (luôn là hướng phía trước)
|
||
|
|
moveDirection = direction.normalized;
|
||
|
|
}
|
||
|
|
|
||
|
|
void Start()
|
||
|
|
{
|
||
|
|
Destroy(gameObject, lifetime);
|
||
|
|
}
|
||
|
|
|
||
|
|
void Update()
|
||
|
|
{
|
||
|
|
// Di chuyển đạn theo hướng đã gán, bất kể góc xoay hiển thị của nó là gì
|
||
|
|
transform.position += moveDirection * speed * Time.deltaTime;
|
||
|
|
}
|
||
|
|
}
|