Change event location to position on the screen

Nilom

Veteran
Veteran
Joined
Sep 9, 2013
Messages
178
Reaction score
39
First Language
German
Primarily Uses
RMMV
Hello people.

Currently I'm trying to figure out how I can move events to a position on the screen/view field of the player. I know how to move events with a script call:

$gameMap.event($variable).setPosition(x , y)

But how can I set the x and y position relative to the screen?

I mean something like this:
$gameMap.event($variable).setPosition(screen_x/2-400, screen_y/2)

Thanks in advance! :D
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,260
Reaction score
7,138
First Language
German
Primarily Uses
RMMV
you don't need any script call at all.

1) control variable to set the value of a variable to the player y position
2) control variable to set the value of a different variable to the player y position
3) control variable to change the two coordinates depending on where you want the event relative to the player position
4) set event location command with the variables above as target.

everything done by event commands without a single letter of scripts
 

Nilom

Veteran
Veteran
Joined
Sep 9, 2013
Messages
178
Reaction score
39
First Language
German
Primarily Uses
RMMV
The problem is that there is no player position. Well, there is but the camera is not following the invisible "player" who stands somewhere on the map without further use. It is following events.

Can you help me out with this type of setup? :D


Edit, some more explanation:

I want to build an event based battle system. When the battle starts I need to reposition the character events. I want to use a script call for this because I need to use arrays for the event selection "event(enemy)".
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,260
Reaction score
7,138
First Language
German
Primarily Uses
RMMV
It doesn't matter, the commands and the principles are the same - you can get any event's position in the same way as the player position.
you need to use control variables (or the script equivalent of that command, check the equivalent topic for that) to get a position on the screen before you can use the set position command.

And all events use map coordinates, NOT pixel coordinates, unless you changed the entire structure by using a pixel movement plugin.
there are ways to calculate between pixel coordinates and map coordinates, but the pixel coordintes on the screen will not work with the setposition for events because events use map coordinates.
 

Nilom

Veteran
Veteran
Joined
Sep 9, 2013
Messages
178
Reaction score
39
First Language
German
Primarily Uses
RMMV
(or the script equivalent of that command, check the equivalent topic for that)
Thank you. I guess there I will find what I'm looking for.

And all events use map coordinates, NOT pixel coordinates, unless you changed the entire structure by using a pixel movement plugin.
there are ways to calculate between pixel coordinates and map coordinates, but the pixel coordintes on the screen will not work with the setposition for events because events use map coordinates.
Ah that's good to know. I will have to find a workaround for this. Predetermined coordinates will not work for me, as some events may be off-screen. Is there a way to ask the cameras/views center coordinates? That would help.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,696
Reaction score
3,006
First Language
Tagalog
Primarily Uses
RMVXA
IIRC

You can actually calculate the grid coordinate of the screen coordinate via some calculations.. But you'd need to take into account the map size and screen size to convert it correctly.

There's a part of the default code that handles screen x and y, you can try to look for it and see what can be done.
 
Last edited:

Nilom

Veteran
Veteran
Joined
Sep 9, 2013
Messages
178
Reaction score
39
First Language
German
Primarily Uses
RMMV
Oh, map size and screen size may vary vastly between maps and users (mobile phones).

There's a part of the default code that handles screen x and y, you can try to look for it and see what can be done.
Thanks I try to find that.
 

Eliaquim

Raze: The Rakuen Zero's Guardian!
Veteran
Joined
May 22, 2018
Messages
1,358
Reaction score
605
First Language
Portuguese - Br
Primarily Uses
RMMV
Oh, map size and screen size may vary vastly between maps and users (mobile phones).
Thanks I try to find that.
I think it is
Event - $gameMap.event(eventID).screenX();
player - $gamePlayer.screenX();

This will calculate the position in pixels of the event and player. Just use X or Y.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,696
Reaction score
3,006
First Language
Tagalog
Primarily Uses
RMVXA
Oh, map size and screen size may vary vastly between maps and users (mobile phones).
Doesn't matter because you can get the map and game window size via script calls available.

@Ellaqium - he is trying to do the reverse, use screen x/y to set an event's position but he first needs to determine what value of screen x/y to use because he doesnt have a reference point somehow (his camera doesnt follow the player)

By default, the game doesnt have a camera because it is set to simply adjust the map depending on the player's location.

So what camera system are you using that allows you to move it without centering on the player? That system itself probably has a script call that we can use to get the camera center coordinates. That would be the best reference point to use.
 
Last edited:

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

Latest Threads

Latest Posts

Latest Profile Posts


It's my cute little ghost~
Minecraft Dungeons is a great example of a game that's much simpler than other games in its genre but almost as equally immersive and fun to play. Lotta RPGmaker devs could learn from that lesson.
Well, it's been a while since the last time I came here... Is there a JS scripting FAQ? I'd like to know what it's capable of achieving, and how :rswt
I love the Time Fantasy tiles, but haven't played anything made with it yet. Can anyone recommend me something?
Vote for what I show more indepth on Twitter tomorrow from the MZ default resources

Forum statistics

Threads
99,373
Messages
964,561
Members
130,981
Latest member
jimmydark
Top