Search Unity

Need some suggestion

Discussion in 'Scripting' started by JeevanjotSingh, Nov 20, 2014.

  1. JeevanjotSingh

    JeevanjotSingh

    Joined:
    Apr 30, 2014
    Posts:
    251
    Hi guys
    I am working on my First Game

    and i am a little bit confuse about logic .
    I have a player ball if it leaves the platform then it should be destroy because sometimes my enemy push my player in the corner and it will Exit the collide of the player ball from the platform .
    So when i use



    Code (CSharp):
    1. void OnCollisionExit(Collision col)
    2.     {
    3.         if(col.transform.tag =="Ground"){
    4.  
    5.         Destroy(gameObject);
    6.         }
    7.     }
    8.  

    then player destroy when it make a small jump by crashing with walls or just destroy when anything game object touches and exit collision from it or .
     
    Last edited: Nov 20, 2014
  2. lorenalexm

    lorenalexm

    Joined:
    Dec 14, 2012
    Posts:
    307
    So instead of using the OnCollisionExit method, you could create another MonoBehaviour and use the OnTriggerEnter method then create colliders marked as triggers to designate the area where the player is supposed to 'die'.

    Also, this should be placed in the Scripting sub-forum.
     
  3. JeevanjotSingh

    JeevanjotSingh

    Joined:
    Apr 30, 2014
    Posts:
    251
    Ok thanks , next time i will keep this in my mind .