|
|
@ -9,6 +9,8 @@ public class MissileController : MonoBehaviour { |
|
|
|
public float initVelocity = 5; |
|
|
|
public float boostCoolDown = 0.3f; |
|
|
|
public float difficulty = 0.0f; |
|
|
|
public int totalBoosts = 2; |
|
|
|
|
|
|
|
public ParticleSystem boostEffect; |
|
|
|
public GameObject Explosion; |
|
|
|
|
|
|
@ -42,20 +44,20 @@ public class MissileController : MonoBehaviour { |
|
|
|
|
|
|
|
rigid = GetComponent<Rigidbody2D>(); |
|
|
|
rigid.velocity = startVelocity * initVelocity; |
|
|
|
Destroy(gameObject, 1.5f); |
|
|
|
Destroy(gameObject, boostCoolDown * totalBoosts + 1); |
|
|
|
} |
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
void FixedUpdate () { |
|
|
|
|
|
|
|
if (Time.time - startTime >= boostCoolDown && reCalibrate < 2) { |
|
|
|
if (Time.time - startTime >= boostCoolDown && reCalibrate < totalBoosts) { |
|
|
|
if (reCalibrate == 0) { |
|
|
|
targetPos = target.transform.position; |
|
|
|
if (target != null) { |
|
|
|
targetPos = target.transform.position; |
|
|
|
} |
|
|
|
} |
|
|
|
if (target != null) { |
|
|
|
moveTorwards(target); |
|
|
|
} else { |
|
|
|
moveTorwards(targetPos); |
|
|
|
} |
|
|
|
reCalibrate++; |
|
|
|
startTime = Time.time; |
|
|
@ -79,6 +81,9 @@ public class MissileController : MonoBehaviour { |
|
|
|
} |
|
|
|
|
|
|
|
private void moveTorwards(GameObject target) { |
|
|
|
if (target == null) |
|
|
|
return; |
|
|
|
|
|
|
|
if (targetRigid != null && reCalibrate == 1) { |
|
|
|
Debug.DrawLine(targetPos, target.transform.position, Color.blue, 0.3f); |
|
|
|
Vector2 pos = Vector3.Lerp( targetPos,target.transform.position,difficulty); |
|
|
|