|
@@ -19,6 +19,8 @@ public class Bullet : MonoBehaviour
|
|
|
public BulletType bulletType;
|
|
public BulletType bulletType;
|
|
|
public bool isGetTarget = false;
|
|
public bool isGetTarget = false;
|
|
|
public float speed;
|
|
public float speed;
|
|
|
|
|
+ public float maxDistance;
|
|
|
|
|
+ Vector3 startPos;
|
|
|
|
|
|
|
|
private void Awake()
|
|
private void Awake()
|
|
|
{
|
|
{
|
|
@@ -26,8 +28,18 @@ public class Bullet : MonoBehaviour
|
|
|
rb = GetComponent<Rigidbody>();
|
|
rb = GetComponent<Rigidbody>();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void FixedUpdate()
|
|
|
|
|
+ {
|
|
|
|
|
+ if ((transform.position - startPos).magnitude >= maxDistance)
|
|
|
|
|
+ {
|
|
|
|
|
+ isGetTarget = true;
|
|
|
|
|
+ gameObject.SetActive(false);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public void BeShoot(Character own, Vector3 shootPos, Vector3 dir, int dmg, Vector3 fc)
|
|
public void BeShoot(Character own, Vector3 shootPos, Vector3 dir, int dmg, Vector3 fc)
|
|
|
{
|
|
{
|
|
|
|
|
+ startPos = shootPos;
|
|
|
transform.position = shootPos;
|
|
transform.position = shootPos;
|
|
|
transform.right = -dir;
|
|
transform.right = -dir;
|
|
|
gameObject.SetActive(true);
|
|
gameObject.SetActive(true);
|
|
@@ -40,6 +52,11 @@ public class Bullet : MonoBehaviour
|
|
|
|
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
private void OnTriggerEnter(Collider other)
|
|
|
{
|
|
{
|
|
|
|
|
+ if (other.CompareTag("Plane"))
|
|
|
|
|
+ {
|
|
|
|
|
+ isGetTarget = true;
|
|
|
|
|
+ gameObject.SetActive(false);
|
|
|
|
|
+ }
|
|
|
if (isGetTarget)
|
|
if (isGetTarget)
|
|
|
{
|
|
{
|
|
|
return;
|
|
return;
|