playMaker

Author Topic: [SOLVED] Holding the mouse button down  (Read 6920 times)

ElBueno

  • Playmaker Newbie
  • *
  • Posts: 10
[SOLVED] Holding the mouse button down
« on: July 06, 2012, 12:21:36 PM »
I want to implement a control mechanism in which the player holds a mouse button down to move the character, like in Diablo. Problem is, the Get Mouse Button Down action only sends its event when the button is first pressed down, not when it is held down.

Attached is what I have right now. It works perfectly, but the target only gets set when the player first clicks the button, not when they hold it down. How do I go about setting an action to send an event whenever the mouse button is held down?
« Last Edit: July 06, 2012, 12:39:19 PM by ElBueno »

ElBueno

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Holding the mouse button down
« Reply #1 on: July 06, 2012, 12:39:06 PM »
Heh. Ended up solving this myself. Instead of looking for Mouse Down, I set an axis in the Input Manager to Mouse1 and waited for that axis > 0.0. Yay!

Uttpd

  • Junior Playmaker
  • **
  • Posts: 70
Re: [SOLVED] Holding the mouse button down
« Reply #2 on: July 07, 2012, 06:52:01 PM »
Can you elaborate on your solution? was looking in to the same ;)

 

ElBueno

  • Playmaker Newbie
  • *
  • Posts: 10
Re: [SOLVED] Holding the mouse button down
« Reply #3 on: July 08, 2012, 03:15:52 PM »
Yep! It's pretty simple. In Unity's Input Manager, set an axis to respond to Mouse1. The default settings already have this set as the Fire1 axis. You then use a Get Axis action in PlayMaker to read "Fire1", store the value, and then do a Float Compare action on it to see if it's greater than 0. Nothing more to it than that! :)

Uttpd

  • Junior Playmaker
  • **
  • Posts: 70
Re: [SOLVED] Holding the mouse button down
« Reply #4 on: July 09, 2012, 08:27:54 AM »
Thanks, got me on the right track.

My character is now moving to my target while mouse is down .. Using the Mouse X/Y and Set Position
"only Problem" is that the cursor is offset to the origin (down left corner)
space to Self/ world is the same,  with Normalize on = does not move ...

Uttpd

  • Junior Playmaker
  • **
  • Posts: 70
Re: [SOLVED] Holding the mouse button down
« Reply #5 on: July 10, 2012, 09:43:10 AM »
Got it working,

"Get Mouse X/Y"  offsets from the lower left corner of the camera/ screen (I presume is something in the way 2DToolkit cameras are rigged). So I add this vector to the mouse and bam, working

Bonus since I´m not using "Mouse Pick"  there´s no need for a plane with collider to move on
« Last Edit: July 10, 2012, 09:44:50 AM by Uttpd »