Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Nietzsche on August 31, 2019, 11:28:09 AM

Title: click specific object? [SOLVED]
Post by: Nietzsche on August 31, 2019, 11:28:09 AM
hello,
can someone help me please. I am using the action: "getmousebuttondown" a few times in my project. Standard stuff, I want to select a unit before I can move it and so on. My problem is now, that since multiple objects use the command "getmousebuttondown" they all play at the same time, even if they shouldn't.

That is an extreme problem with the ui. Do you guys maybe no a diffrent command for that, that can help me with my problem?
Title: Re: click specific object?
Post by: TheNecron on August 31, 2019, 01:26:15 PM
Get Mouse Button Down triggers whenever any click event occurs regardless of where the mouse is. I'm not knowledgeable enough to know what action you're looking for, maybe try Mouse pick?
Title: Re: click specific object?
Post by: djaydino on August 31, 2019, 01:39:55 PM
Hi.
As TheNecron mention.

Mouse pick can be useful here

You still need to use mouse button down, to know if the mouse button was clicked.
Then after "getmousebuttondown" do the mouse pick. and store the object in a variable.

With layers you can make sure only certain layers can be picked.
(you can set layers on object in the top right of the inspector, be aware that you have a limit of 32 layers)

You can set a layer an name it for example Units, then you can also set a tag to give  a more specific reference (for example 'melee soldier')
Title: Re: click specific object?
Post by: Nietzsche on August 31, 2019, 02:55:59 PM
thank you for the help I will try to implement that  :)
Title: Re: click specific object?
Post by: Nietzsche on August 31, 2019, 03:51:35 PM
thank you for the tip with "mousepick" works very well, just to tell, I made it so that I click an object first, safe the object I pick in a viriable and compare that variable to the object I actually wanted to move. With this it worked well so far, or ist there anything bad about it?

And one thing still doesn't work, how do I use the mouse pick for my UI?

So far mouse pick didn't detect the UI but the physical object beneath it, or do I need to ad a physical layer to the UI?
Title: Re: click specific object?
Post by: tcmeric on August 31, 2019, 10:18:14 PM
These videos might help you get started:
Title: Re: click specific object?
Post by: Nietzsche on September 01, 2019, 03:47:58 AM
I will watch them throu, thanks m8
Title: Re: click specific object?
Post by: stigma on September 01, 2019, 05:46:15 AM
I had a lot of trouble with that. Now I only use MouseDown and it works very well.
Title: Re: click specific object?
Post by: Nietzsche on September 01, 2019, 08:21:05 AM
jo, I watched all of that rts series, and while it was certainly helpfull, it still doesn't solve my button pressing issue.

Same question, do I need to add some kind of physical layer to the buttons?
Or could it be better to not use playmaker for the ui but normal scripting?
Title: Re: click specific object?
Post by: djaydino on September 01, 2019, 12:45:58 PM
Hi.
Mouse pick does not work on ui.

You have several dedicated UI actions.
For example : Ui Button On Click Event
Title: Re: click specific object?
Post by: Nietzsche on September 01, 2019, 04:07:35 PM
I am sorry, but I don't really understand how this action works. What exactly triggers it? And if it is triggered anytime I press a ui button, then I will end up with the same problem.

more specificly: can I safely trigger only one button with an playmaker action by clicking on it, or is that achievable with "UI Trigger event"
Title: Re: click specific object?
Post by: Nietzsche on September 02, 2019, 07:29:46 AM
thanks for you help guys. I got my problem solved