Trigger Common Event by Clicking on Player

chalkdust

Resource Staff
Restaff
Joined
Mar 23, 2015
Messages
360
Reaction score
553
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
99
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
553
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
99
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
553
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!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Bleaching my whole head so I can dye it green. Hopefully I don't fry it all off. Pray for me.
Completed my game's menu! :LZScheeze: (Game Title: ⟁False Server)
Also showcasing Galv_ChoicePictures.js by Galv
and,
AKUNOU_Option plugins by Tsutumi Kawahara.
(More details in the video description on YouTube.)

1 million messages is approaching. The end is near! M1M is like Y2K, but forum based. It's a bug that's gonna delete all attachments when we hit 1 mil messages. At least with Y2K we had warning....
If you manage to make a game that people play for hours, then reminding them to take a break gives that “This game cares about me” feeling and also lowers chance of burnout with your game.

Forum statistics

Threads
103,432
Messages
999,264
Members
134,963
Latest member
walkerjamesm
Top