Destroy on Pointer Click

Epocson 11 months ago updated 11 months ago 6

Forgive the simple question.  I'm about a week into unity.

I have a 2D instantiated sprite.  I would like it to be destroyed (or trigger a destroyed animation eventually) when I click it with the pointer.  I've tried simple ways, I've tried complex raycast things... nothing seems to work.  Thanks for the help!

Bolt Version:
Unity Version:
Not sure yet
Scripting Backend:
.NET Version (API Compatibility Level):
.NET 4.x

This is in a flow graph on a GameObject thats in the scene and enabled?

Make a Debug.DrawRay(start, direction) unit.  For "start" get the Ray.origin from the ray you made, and for direction, get Ray.direction * max distance.  This will create a ray gizmo in the scene view that will let you visualize where your ray is going, to make sure it is working.

I would also recommend putting the output of "get collider" into a debug.log(message), so you can see in the console what exactly is getting hit (if anything).  


+ probably you need use raycast 2d + collider 2d

I have switched everything to the Physics 2D and it still doesn't work.  I will provide a screenshot here shortly.  Thanks for your help guys.  I'll post it here once I get home.

Updated attempt, still not working.  Any thoughts?

try this flow on sprite if it works then try raycast


That worked, thank you so much!