|
@@ -21,8 +21,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;
|
|
|
|
|
|
|
+ public float maxFlyTime = 2f;
|
|
|
|
|
+ public float flyTime;
|
|
|
public bool isTrack;
|
|
public bool isTrack;
|
|
|
public Character trackTarget;
|
|
public Character trackTarget;
|
|
|
|
|
|
|
@@ -34,7 +34,8 @@ public class Bullet : MonoBehaviour
|
|
|
|
|
|
|
|
private void FixedUpdate()
|
|
private void FixedUpdate()
|
|
|
{
|
|
{
|
|
|
- if ((transform.position - startPos).magnitude >= maxDistance)
|
|
|
|
|
|
|
+ flyTime += Time.deltaTime;
|
|
|
|
|
+ if (flyTime >= maxFlyTime)
|
|
|
{
|
|
{
|
|
|
isGetTarget = true;
|
|
isGetTarget = true;
|
|
|
gameObject.SetActive(false);
|
|
gameObject.SetActive(false);
|
|
@@ -50,7 +51,6 @@ public class Bullet : MonoBehaviour
|
|
|
|
|
|
|
|
public void BeShoot(Character own, Vector3 shootPos, Vector3 dir, int dmg, float fc, bool hurt, float time, bool track = false, Character target = null)
|
|
public void BeShoot(Character own, Vector3 shootPos, Vector3 dir, int dmg, float fc, bool hurt, float time, bool track = false, Character target = null)
|
|
|
{
|
|
{
|
|
|
- startPos = shootPos;
|
|
|
|
|
transform.position = shootPos;
|
|
transform.position = shootPos;
|
|
|
transform.right = -dir;
|
|
transform.right = -dir;
|
|
|
gameObject.SetActive(true);
|
|
gameObject.SetActive(true);
|
|
@@ -63,6 +63,7 @@ public class Bullet : MonoBehaviour
|
|
|
rb.velocity = dir * speed;
|
|
rb.velocity = dir * speed;
|
|
|
isTrack = track;
|
|
isTrack = track;
|
|
|
trackTarget = target;
|
|
trackTarget = target;
|
|
|
|
|
+ flyTime = 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
private void OnTriggerEnter(Collider other)
|