How to get a click on object command working?

Hi there im wondering if anyone out there can help me. This is my very first time using UE but i keep hitting a brick wall with the blueprint like for instance i need to make a control that i can click on a static mesh and destroy it…
now it works perfect when i assign a key but i need it to work when i physically click on the object.
iv been trying to work this out for 8 hours now and im all out of ideas the trigger just does not fire at all.
any help would be appreciated
here is what i have so far

Try using Left Mouse Button node as the event originator.

hi zeustiak that does work however that’s if i click anywhere i need it so that when i click on the object it triggers

Hey,

Try giving this a shot:

Swap out Shape_Cube for your “MyMesh” actor. The Blueprint above returns what was under the mouse cursor when clicking and if it is equal to the mesh provided (Shape_Cube in my example) then execute the script following the Branch (which just prints a string now - but you can Destroy Actor and Play Sound after the branch).

Hope this helps,

-W

Thanks wesbun i’ll give this a go

Hey wesburn copied it exactly too see if i can get that script up first and still no fire when clicked on :frowning:

mine is also in the LevelBlueprint… i’m wondering if i’m missing something else other than the script to get it working

Which Blueprint are you doing the script under? For the example I provided, I was doing it in the LevelBlueprint as it was being used for a Menu (Similar to SwingNinja).

-W

I am also using a different Player Controller for the Menu than the default controller. What controller are you using?

6317-gamemode.png

You’ll have to enable click events in your controller:

6318-gamemenucontroller.png

-W

ah iv taken a controller from one of the example maps (memory one) and been trying to use that as dint know how to create my own

6325-b2.png

i cant seem to find the GameMode anywhere ?

Go to the World Settings option at the top of the tool bar next to the Blueprints button. In there you can set the GameMode and assign your controller.

-W

okay iv done that and it still wont do it… but in the script i can see it firing up to the first branch and nothing after that so some progress

Hmm… just tested this and was able to destroy my block and play a sound with this setup, would you be able to post a video of it in progress? You’re seeing the Blueprint wires activate up to the first Branch when clicking on the object?

-W

iv tried to upload a video in avi, mov and mp4 format but it just says invalid file type all the time what is the file type? iv got a video of it stopping at the first branch, is there an email i could send it to?

Post it to Youtube or something and I can take a look that way, appreciate it. It will help me determine what’s going on as I’ve been able to successfully produce what you are after with the setup I’ve shown.

-W

all done sorry about the poor video quality its the best one i have but hopefully you can tell whats going on, on it here is the link

Thanks for the video, unfortunately I am unable to determine what the issue is based on it. I’ve just created a new project and tested it again and I’m able to get it to work.

Wondering if it has something to do with the mesh asset you are using to click on. Is it a Blueprint that you are using or is it a Static Mesh object. What are the collision settings for the object as well?

hmm strange…it is a static mesh created from the brush tool

6366-static+mesh.png

and the collision settings on it are…

6367-collision+settings.png

So I think I figured out the problem (always something minor you overlook).

Give this a shot, bypass all the branching and hook the OnClicked event directly up to your destroy actor like you did in your first post.

You don’t need the Get a Hit Result or any of the Branching because the OnClicked event is already registered to determine if it was the specific object that was clicked on (in a project I’ve created, I have a Confirm event which is tied to Left Mouse Click - rather than specifying if a specific object was clicked which is why I needed the checking to occur, for your example you shouldn’t need it).

Clicking anywhere but on the mesh shouldn’t do anything while clicking on the mesh should register and fire off any events that follow it.

-W

yeah its all working now :slight_smile: always the smallest of things
Thanks again