Search Unity

getting the gameobject from the collider he's got

Discussion in 'Scripting' started by Gaba, Aug 24, 2009.

  1. Gaba

    Gaba

    Joined:
    May 29, 2009
    Posts:
    41
    ok, i'm using raycasts to see if i left clicked an object, but the hit returns me the collider, and i cant seem to call the game object from that collider

    i wanted to be able to see if that raycast hit anything, and if it did(i got this part already) call a function on the object it hitted

    tips? suggestions?
     
  2. GargerathSunman

    GargerathSunman

    Joined:
    May 1, 2008
    Posts:
    1,571
    collider.gameObject.SendMessage("FunctionName", PassedVariable);
     
  3. Gaba

    Gaba

    Joined:
    May 29, 2009
    Posts:
    41
    i thought the GameObject had the collider, and not the other way around

    thanks for the reply
     
  4. GargerathSunman

    GargerathSunman

    Joined:
    May 1, 2008
    Posts:
    1,571
    If you look at the classes inside the Unity scripting reference, the variables go both ways. It's under "Inherited Members" in the reference.
     
  5. Gaba

    Gaba

    Joined:
    May 29, 2009
    Posts:
    41
    awesome, this engine just keeps getting better and better


    thanks a lot