Nilom

Regular
Regular
Joined
Sep 9, 2013
Messages
178
Reaction score
40
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

Regular
Regular
Joined
Mar 5, 2013
Messages
39,918
Reaction score
11,871
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

Regular
Regular
Joined
Sep 9, 2013
Messages
178
Reaction score
40
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

Regular
Regular
Joined
Mar 5, 2013
Messages
39,918
Reaction score
11,871
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

Regular
Regular
Joined
Sep 9, 2013
Messages
178
Reaction score
40
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'
Regular
Joined
May 15, 2012
Messages
14,693
Reaction score
3,035
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

Regular
Regular
Joined
Sep 9, 2013
Messages
178
Reaction score
40
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

Hakuen Studio
Regular
Joined
May 22, 2018
Messages
3,357
Reaction score
2,668
First Language
Portuguese - Br
Primarily Uses
RMMZ
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'
Regular
Joined
May 15, 2012
Messages
14,693
Reaction score
3,035
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:

Latest Threads

Latest Posts

Latest Profile Posts

I've been watching videos about the videogame streamer Open Hand charity scandal, and the rabbit hole keeps getting deeper. At first it was just a lot of donated money being grossly neglected for years, and now there's a lot of money unaccounted for, which could turn this into a legitimate IRS crackdown.
Let's have some fun with my advent calendar. What would you like to see for Day 3: land, sea, or air? :rheh:
I've been thinking about doing a jokey submission for the Christmas jam in which, like a cartoon special where all the characters "play" a counterpart in A Christmas Carol, my MagiCats would each play a role from the C.A. Smith story The Coming of the White Worm, with Cyprian as Evagh, Rousalie as Dooni and so forth. But in the end, I figure all my development efforts should go toward the game proper.
In twitter, square phoenix had successfully prompted chatgpt to make the mini game watermelon pangpang.

drew some stuff to see how frontview might look. not entirely sold on or off of it yet. "could" work, but something feels missing.

Forum statistics

Threads
136,697
Messages
1,268,894
Members
180,412
Latest member
LoftTheSkyWarrior
Top