Download

Mouse Click Distance Help

I have a Sidescroller im working on and im using mouse clicks in it to interact with actors. Right now i can click on any object and have it do its function anywhere. How can i fix it to be near an object before the clicks work?
character

Something like get the object location minus the location of the clicked actor and querying the length of the vector?

Call GetActorLocation on the actor that is clicked and on the actor you want to the interaction range to be limited to (your character?). Subtract the resulting vectors of the 2 GetActorLocation from each other and use the node VectorLength on the resulting vector. Check if that VectorLength is smaller than ("<" node) than your desired distance. Plug the resulting into the condition node of a branch. Execute whatever logic you want to execute on interacting only after the True output of your branch.

Thanks that worked. For some reason i though i had to deal with mouse position and everything thats what i was stuck on :stuck_out_tongue: