Search Unity

GetMouseButton - How do I check for the target?

Discussion in 'Scripting' started by Findo, Apr 7, 2014.

  1. Findo

    Findo

    Joined:
    Mar 11, 2014
    Posts:
    368
    How would I check for the target, so like, if a player clicked a cube it would do Debug.Log("Clicked");?
     
  2. Fellshadow

    Fellshadow

    Joined:
    Dec 2, 2012
    Posts:
    169
    This is how.
    For the 1000th time, look stuff up before making a thread.
     
  3. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
  4. Findo

    Findo

    Joined:
    Mar 11, 2014
    Posts:
    368
    Fellshadow, for the 1000th time, I DID! In fact the thing that you searched showed what I clicked. (was highlighted in purple).
    I found OnMouseDown, but wasn't sure if that detected for the gameobject the script is inside, but because DanielQuick says so, I guess it does.
     
  5. Fellshadow

    Fellshadow

    Joined:
    Dec 2, 2012
    Posts:
    169
    Well those links show you exactly what you have to do, and is exactly how I figured out how to do it when I first started Unity.
    You have to actually look at what they say....
     
    Last edited: Apr 7, 2014
  6. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    Had you actually tried it before posting you would have found out for yourself. Seriously - stop being a dick when people request that you do some legwork yourself.
     
  7. Findo

    Findo

    Joined:
    Mar 11, 2014
    Posts:
    368
    Just looking back at this, and a few other posts, and I see Kelso ain't very friendly. Sry for bump, this can be locked :D