chalkdust

Resource Staff
Restaff
Joined
Mar 23, 2015
Messages
360
Reaction score
564
First Language
English
Primarily Uses
RMMV
I want to trigger a common event when you click on the player character in RMMV.

Any thoughts on the most efficient way to do this?
 

dahlys

Meatbun
Veteran
Joined
Aug 28, 2017
Messages
95
Reaction score
101
First Language
English
Primarily Uses
RMMV
Toss this into the conditional branch to check if the player character is being clicked on. I'm assuming you're using a 48x48 tile size.
Code:
Math.floor(TouchInput._x/48) === Math.floor($gamePlayer.screenX()/48) && Math.floor(TouchInput._y/48) === Math.floor($gamePlayer.screenY()/48)

Remember to do a script call to clear the clicked data after the event is over. Otherwise, your common event is going to loop.
Code:
TouchInput.clear()

BTW, nice resources you have there! I'm downloading them XD
 
Last edited:

chalkdust

Resource Staff
Restaff
Joined
Mar 23, 2015
Messages
360
Reaction score
564
First Language
English
Primarily Uses
RMMV
Awesome! Thanks so much. That script works perfectly. Unfortunately, I have MouseSystemEx installed and it's causing it to activate on hover, so I'll have to find a workaround for that little hiccup. I'm going to have to do some tinkering to disable MouseSystemEx when I'm not in the menu. Thanks again!
 

dahlys

Meatbun
Veteran
Joined
Aug 28, 2017
Messages
95
Reaction score
101
First Language
English
Primarily Uses
RMMV
Does it work if you add
Code:
Input.isPressed('ok')
to the condition? Hopefully this will place an extra check if the left mouse button is clicked.
 

chalkdust

Resource Staff
Restaff
Joined
Mar 23, 2015
Messages
360
Reaction score
564
First Language
English
Primarily Uses
RMMV
Not quite, but a separate condition check for TouchInput.isPressed() solved both the compatibility problem and a different problem (where it would trigger after moving to a clicked location). Thanks a ton for your help!
 

Latest Threads

Latest Profile Posts

so... I decided since a park was an area in my game... here's an enemy that's slide with a hand behind it. cause why not.
Hot chocolate and music make studying and note-taking much easier :kaoluv:
Until my hand cramps up from writing too much!
Doing RPG Maker News for 21st September 2021


Malak is still waiting for Dark Deception Chapter 4... This was him yesterday after another sugar crash.
Again, he's fine. He's just bored at this point, considering he's exhausted his entire vacation bucket list.
Am I the only one who files custom resources under specific folders to remember who to credit? :kaoswt2:
1632263519730.png

Forum statistics

Threads
115,267
Messages
1,088,462
Members
149,872
Latest member
ghosted
Top