Chapter 19 - Making Towers : Event System, Event Trigger

I totally understand why projects come with a lot of the hard work implement and help us focus on the core parts.

My question relates to the Event System and Event Trigger.

If I wanted to recreate a brand new project with the event system and an game object with an event trigger, I just can’t trigger the event when the mouse hovers over or mouse press the game object.

  1. Create Empty object and name it Event System. Add Event System and Input Standalone Module components

  2. Create a quad or a cube, whichever. Add a 3d box collider, script with a public void TriggerMe method. Add a Event Trigger component, create a trigger, choose the event, drag on the script that is attach to the object and pick the method from the list.

When I run the game, and look at the information on the Event System, I do get any messages when the mouse performs any of the trigger events on the game object.

What is the key mistake I am making. I thought I have replicated the Tower Defence project but am missing something. Can someone help. I have reverted for now to the OnMouseDown method in the script attached the object which works but would like to use the event system.

I love the effort the team has placed into every book and every project I have the opportunity to recreate. Thank you.


Hi Jean-Noel!

I think you have all the needed components, but you forgot to derive your script from IPointerClickHandler. Check out the documentation below:

To get this to work you need a public method with this signature:

public void OnPointerClick([PointerEventData)

Everything you put in there will be called when you click on the attached collider.
You might also need to add a PhysicsRaycaster component on your main camera GameObject so the event system picks up clicks on 3D colliders.

There are also a bunch more interfaces you can derive from for additional behavior, check out the list on the left of this page:

Everything starting with “I” can be used with the event system.

I hope that helps!


Hi Eric, Thank you for taking the time to answer this. I’ll give it a go over the weekend and let you know the outcome.


Thank you. You actually pointed me to a good resource that lead me to the answer I was looking for. I only really needed to add a Physic Raycaster to the camera

1 Like

This topic was automatically closed after 166 days. New replies are no longer allowed.