Search Unity

Character collision death

Discussion in 'Scripting' started by DarkNeo, May 2, 2014.

  1. DarkNeo

    DarkNeo

    Joined:
    Apr 27, 2014
    Posts:
    53
    Hi there, I have managed to get my character to die successfully if you are playing the game, however I have noticed that if you are not playing the game and just leave it to run, the character does not die and the level continues scrolling on. I'm currently using an OnTriggerEnter for my death zone area for the character.

    Code (csharp):
    1. function OnTriggerEnter (other : Collider)
    2. {
    3. //Checks if the Character is colliding with object
    4. if (other.name == "Character")
    5.  
    6.  
    7. {
    8.  
    9. //resets level
    10. Application.LoadLevel("tryagain");
    11.  
    12.    
    13.   }
    14. }

    I have played for hours with OnControllerColliderHit and other Collision type functions and I still can't get it to work.

    I basically need it so if you are playing the game or not, either way your character will die the moment it touches the death area. I hope someone can please help me! thanks again :)
     
    Last edited: May 2, 2014