Selecting Characters with Mouse Click

Hi, I am trying to make a sim game where there is no "Main" character. So basically there are several characters in the map randomly moving and when I click on one of those characters with the mouse then I'll select that character. Once selected I can then make that character move to where I click my mouse. Then I right click to deselect it or I simply click on another character. Is this possible? Additionally, is there a way to bind an event to right click?



Here's what I tried before:
- I set maincharacter to transparent.
- Made my characters as events.
- I used TDD Mouse System to activate a character by clicking on it.
- I changed the party setup so the old transparent character is removed and replaced by the new character that I clicked then deleted that event. However when I do this, then the position of my character is off. I tried to change the position of my character to where the event was standing when I clicked it but I don't know how to get the current x,y coordinates of a moving event once it is activated. Can someone help me? Or is there an easier way to do this?

Thanks!
you'll need to use control variable command to get the positions of any event on the map.

The way you started is the correct one, please show a screenshot of your current event pages and we can tell you where you made mistakes and how to improve them.
This is what I have


As you see in the 2nd picture if I click on the moving event I succesfully makes my main character that event effectively "selecting" it. But the position is still in the middle(The position of my previous hidden main character). How do I get the x,y of the moving event at the time I activated it?
as I said, you need to use the control variable command to get the X and Y position of the event into two variables (control variables : game data : character : event : map x) - that is one of the most basic uses for variables.

I suggest you follow the link to the starting point in my signature and work through the tutorials listed there, especially the variables guide. There is no difference in handling variables between Ace and MV, so you can use all that.
EDIT: Nvm I totally missed the game data option. Thanks for this!

About my other concern, do you also know how to bind events to right click?
It looks like they built a handler for the right mouse button in the core, but they just cancel it.
PHP:
TouchInput._onRightButtonDown = function(event) {
    var x = Graphics.pageToCanvasX(event.pageX);
    var y = Graphics.pageToCanvasY(event.pageY);
    if (Graphics.isInsideCanvas(x, y)) {
        $gameTemp.reserveCommonEvent(1); // <= I suppose you would put it here...
        yourFunction(x, y); // <= or maybe this
        this._onCancel(x, y);
    }
};
var yourFunction = function(x, y) { // <= for option two
    $gameVariables.setValue(1, x);
    $gameVariables.setValue(2, y);
    $gameTemp.reserveCommonEvent(1); // the common event refers to variables 1 and 2 for x and y where the mouse clicks
};
I'll check this out when I get home. Which js is this?
It's in rpg_core.js
He's right. TouchInput is in rpg_core.js

pageToCanvasX and Y make the pageX and Y into canvas relative coordinates.

The more I think about it after I post, the common event in your function will probably need the tile coordinates for your function, instead of the mouse coordinates.
PHP:
var yourFunction = function(x, y) { // <= for option two
    $gameVariables.setValue(1, Math.round(x / 48) + $gameMap._displayX);
    $gameVariables.setValue(2, Math.round(y / 48) + $gameMap._displayY);
    $gameTemp.reserveCommonEvent(1); // the common event refers to variables 1 and 2 for x and y where the mouse clicks
};

I also just learned that _onCancel does in fact cancel the event to keep the Chrome right click context menu from popping up, but it also activates something tied in the event to open the game menu.
Add this boolean before the _onCancel and it shouldn't open the menu.
PHP:
if(SceneManager._scene._mapLoaded === undefined)
   this._onCancel(x, y); // only right click menu button in menu

Tinkering to figure out how to boolean the menu open or not, I discovered Scene_Manager which seems to be a data object without the $ in front like $gameMap etc. So you've helped me 1up my knowledge of MV. Thanks. It was hiding from me.
You can temporarily disable the menu with $gameSystem._menuEnabled = false;
He may still want to open the menu via the keyboard. I wouldn't know where to turn menu back on.

SceneManager._scene._mapLoaded <- is only true when not in the menus, or rather in the maps where I predict the right click common events will take place.

Original thread: https://forums.rpgmakerweb.com/threads/selecting-characters-with-mouse-click.75234/