Check position between Player & Event? HELP

Discussion in 'Javascript/Plugin Support' started by Isabella Ava, Nov 30, 2017.

    Tags:
  1. Isabella Ava

    Isabella Ava Veteran Veteran

    Messages:
    636
    Likes Received:
    751
    First Language:
    English
    Hi guys, please HELP. I want to check position between Player & an Event to see if Player is standing next to it or not
    (Don't want to do this with command events, it's a lot of nest Conditional Branches)

    I found this plugin but i don't know how to use it?
    https://forums.rpgmakerweb.com/index.php?threads/player-vs-event-position-plugin.85046/#post-789983

    I put it into command script like this but it won't work:
    if (this.playerVsThisEventDistance(2))
    {$gameVariables.setValue (222, 2);}

    And i tried to put the script into Conditional Branch command but it won't work too
    [​IMG]

    Please HElp =.+
     
    #1
  2. Shaz

    Shaz Veteran Veteran

    Messages:
    37,549
    Likes Received:
    11,258
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    In a conditional branch in the script section, try this:

    Code:
    Math.abs($gamePlayer.x - $gameMap.event(2).x) + Math.abs($gamePlayer.y - $gameMap.event(2).y) === 1
    That will return true if the player and event are one tile away horizontally or vertically, and false otherwise. If the player and event are one tile away diagonally, it will return false, as the total distance will be 2 tiles (one up/down and one left/right).
     
    #2
    Isabella Ava likes this.
  3. Isabella Ava

    Isabella Ava Veteran Veteran

    Messages:
    636
    Likes Received:
    751
    First Language:
    English
    Oh great, thank you very much
     
    #3

Share This Page