Unity Tutorial: Call Function of Object Clicked by Mouse

Aug 5, 2014

Intended for developers new-ish to Unity, in this latest short video tutorial I explain and demonstrate the common pattern of activating functionality on an object when it’s clicked on by the mouse.

Potential uses include shooting targets, opening doors, flipping switches, commanding RTS units, directing a character in point-and-click adventure games, selecting a piece or tile in a digital board game, and so on.



Learn and practice team game development with Gamkedo Club.
Membership worldwide. Professional support. Proven process.




Subscribe by e-mail to receive weekly updates with Gamkedo.Community interviews and YouTube training videos for game developers!



2 Comments

  1. Varun V P says:

    Nice tutorial Chris! Anyway, if we were to do the same on an Android phone, we would just have to replace Input.MousePosition by Input.TouchPosition (or whatever it is….,) isn’t it?

    Thanks!

    • Chris DeLeon says:

      Prooobbbaaabbbblyyy, although admittedly I’ve only dealt with touch in Unity for one project (ElectroTerrestrials, seven months ago), so off the top of my head I can’t say for sure what the equivalent is. I think there may be an array of touch events to loop through as part of multitouch support, and you can then just grab and treat the first from that array as the mouse coordinate or whatnot.

Leave a comment

Comments Form
  • Your email will not be used for any purpose other than to update you in replies to your comments. Your website address will be shown as a link from your name with your comment. Your profile photo is auto-magically provided by Gravatar.

All contents Copyright ©2017 Chris DeLeon.

Site production by Ryan Burrell.