Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 21st, 2012  |  syntax: None  |  size: 1.40 KB  |  hits: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to add Delay before finding GameObject
  2. if(other.tag == "enemy"){
  3.     other.transform.parent.gameObject.name = ("enemy" + currentEnemy);
  4.     print(other.name);
  5.     gameObject.Find("enemy" + currentEnemy).GetComponent("RagdollOrNot").MakeKinematicFalse();
  6.     BloodParticle.emit = true;
  7.     Stabbed = true;
  8.     Character.GetComponent("MouseLook").enabled = false;
  9.     Character.GetComponent("CharacterMotor").enabled = false;
  10.  
  11. }
  12.        
  13. if(Stabbed == true){
  14.     StopBleeding ++;
  15. }
  16.  
  17. if(StopBleeding > 50){
  18.     Stabbed = false;
  19.     StopBleeding = 0;
  20.     currentEnemy ++;
  21.     Character.GetComponent("MouseLook").enabled = true;
  22.     Character.GetComponent("CharacterMotor").enabled = true;
  23.     BloodParticle.emit = false;
  24. }
  25.        
  26. if(other.tag == "enemy"){
  27.     other.transform.parent.gameObject.name = ("enemy" + currentEnemy);
  28.     print(other.name);
  29.     StartCoroutine("DelayDeath");
  30.     BloodParticle.emit = true;
  31.     Stabbed = true;
  32.     Character.GetComponent("MouseLook").enabled = false;
  33.     Character.GetComponent("CharacterMotor").enabled = false;
  34.  
  35. }
  36.  
  37. private IEnumerator DelayDeath()
  38. {
  39.    //this will return...and one second later re-enter and finish the method
  40.    yield return new WaitForSeconds(1.0f);
  41.    gameObject.Find("enemy" +   currentEnemy).GetComponent("RagdollOrNot").MakeKinematicFalse();
  42. }
  43.        
  44. print("foo");
  45.  yield WaitForSeconds (5.0); // waits for 5 seconds before executing the rest of the code
  46.  print("bar");