Change event location to position on the screen

Discussion in 'RPG Maker MV' started by Nilom, May 1, 2019.

  1. Nilom

    Nilom Veteran Veteran

    Messages:
    178
    Likes Received:
    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:


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

    I mean something like this:

    Thanks in advance! :D
     
    #1
  2. Andar

    Andar Veteran Veteran

    Messages:
    28,304
    Likes Received:
    6,431
    Location:
    Germany
    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
     
    #2
  3. Nilom

    Nilom Veteran Veteran

    Messages:
    178
    Likes Received:
    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: May 1, 2019
    #3
  4. Andar

    Andar Veteran Veteran

    Messages:
    28,304
    Likes Received:
    6,431
    Location:
    Germany
    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.
     
    #4
  5. Nilom

    Nilom Veteran Veteran

    Messages:
    178
    Likes Received:
    39
    First Language:
    German
    Primarily Uses:
    RMMV
    Thank you. I guess there I will find what I'm looking for.

    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.
     
    #5
  6. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,466
    Likes Received:
    2,860
    Location:
    Philippines
    First Language:
    Tagalog
    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: May 1, 2019
    #6
  7. Nilom

    Nilom Veteran Veteran

    Messages:
    178
    Likes Received:
    39
    First Language:
    German
    Primarily Uses:
    RMMV
    Oh, map size and screen size may vary vastly between maps and users (mobile phones).

    Thanks I try to find that.
     
    #7
  8. Eliaquim

    Eliaquim Raze: The Rakuen Zero's Guardian! Veteran

    Messages:
    657
    Likes Received:
    225
    Location:
    Brazil - Rio de Janeiro
    First Language:
    Portuguese - Br
    Primarily Uses:
    RMMV
    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.
     
    #8
  9. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,466
    Likes Received:
    2,860
    Location:
    Philippines
    First Language:
    Tagalog
    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: May 1, 2019
    #9
    Eliaquim likes this.

Share This Page