hey at all,
i’m in trouble. i’ve added a sound to my ship energy shield. it should be played when the shield energy is less than 50%. i’ve done it the same way as i did with other game sounds and never had this prob before. all other sounds are working as expected. not sure but i think this is the first sound effect i want to add since i’ve upgraded to 5.3.2. no matter which import settings i use the best is just a very short scratch when the sound should be played. seems its being cut as soon as it starts to play.
here’s the script: ( i think its ok )
using UnityEngine;
//using System.Collections;
public class SchutzSchild_health : MonoBehaviour
{
public float Schutzschild_hitPoints = 1000f;
public float Schutzschild_currentHitPoints;
public float Schutzschild_curHealth = 100f;
public float Schutzschild_maxHealth = 100f;
public float Schutzschild_my_value ;
public float repairvalue = 10.0f;
public bool damaged = false;
public GameObject destroyFX;
public AudioSource WarningSound;
// Use this for initialization
void Start ()
{
Schutzschild_currentHitPoints =Schutzschild_hitPoints;
WarningSound = GetComponent<AudioSource> ();
}
public void PlayerDamage(float amt)
{
Schutzschild_currentHitPoints -= amt;
//Debug.Log (amt);
if(Schutzschild_currentHitPoints <= 0)
{
Schutzschild_currentHitPoints = 0;
gameObject.SetActive(false);
//Die();
}
}
void Die()
{
if(gameObject.tag == "Player")
{
Instantiate (destroyFX, this.transform.position, this.transform.rotation);
Destroy(gameObject);
}
}
// Update is called once per frame
void Update ()
{
WarningSound = GetComponent<AudioSource> ();
//WarningSound.Stop();
AddjustCurrentPlayer_Health (0);
//Debug.Log(Schutzschild_curHealth + " %");
if(Schutzschild_curHealth <= 50.0f)
{
WarningSound.Play();
}
}
public void FixedUpdate()
{
if(Schutzschild_curHealth < 100.0f)
{
damaged = true;
}
else
{
damaged = false;
}
if(damaged == true && Schutzschild_currentHitPoints > 0)
{
Schutzschild_currentHitPoints += repairvalue * Time.deltaTime;
}
else
{
return;
}
}
public void AddjustCurrentPlayer_Health (float adj)
{
Schutzschild_maxHealth = Schutzschild_hitPoints / 10;
Schutzschild_curHealth = Schutzschild_currentHitPoints / 10;
Schutzschild_curHealth += adj;
if (Schutzschild_curHealth < 0)
Schutzschild_curHealth = 0;
if(Schutzschild_curHealth > Schutzschild_maxHealth)
Schutzschild_curHealth = Schutzschild_maxHealth;
if(Schutzschild_maxHealth < 1 )
Schutzschild_maxHealth = 1;
Schutzschild_my_value = Schutzschild_curHealth / (float)Schutzschild_maxHealth;
}
public void Repairshield()
{
}
}
i’m out of any idea how to solve it now so i would be thankfully for some help.
yours