void Update() { if (GameLogic.GetInstance().IsPlaying()) { if (healthBar != null) { updateHealthBar.setScale(healthManager.getPercentage()); } if (healthManager.currentHealth <= 0) { Destroy(gameObject); } float t = Time.time * 10 + seed; Vector3 offset = new Vector3( Mathf.PerlinNoise(t, t), Mathf.PerlinNoise(-t, t), originalPosition.z); float dir = Time.time < shakeTil ? 1.0f : -1.0f; amount = Mathf.Clamp01(amount + dir * fadeSpeed * Time.deltaTime); transform.position = originalPosition + offset * amount * shakeAmount; } }
void Update() { //Animations // if (currentHitTargetCollision != null) { // // } else { // // Rigidbody2D rb = GetComponent<Rigidbody2D> (); // Vector2 v = rb.velocity; // if (v.magnitude > 0.1f) { // transform.rotation = Quaternion.AngleAxis (Mathf.Atan2 (v.y, v.x) * Mathf.Rad2Deg + 90, Vector3.forward); // // } // } if (GameLogic.GetInstance().IsPlaying()) { if (!died) { if (healthBar != null) { updateHealthBar.setScale(healthManager.getPercentage()); } if (healthManager.currentHealth <= 0) { Die(); } if (currentHitTargetCollision != null) { if (previousHitTime + hitRate < Time.time) { Hit(); } } } else { // dead transform.position = new Vector3(transform.position.x + (directionBeforeDeath.x * 0.1f * ((Time.time - timeOfDeath) * 5)), transform.position.y + (directionBeforeDeath.y * 0.1f * ((Time.time - timeOfDeath) * 5)), transform.position.z - 0.05f); transform.localScale *= 1.03f; } } else { if (GetComponent <Rigidbody2D>() != null) { GetComponent <Rigidbody2D>().Sleep(); } } }