Distance

0 favourites
  • 3 posts
  • Hey people

    I am making a system where if the Player is close enough to a chest, he can access it. I've tried a lot of stuff, but i can't get it working - only on the X axis. I have an event like this:

    When [Chest] left clicked

    [Player] X > Chest.X+250

    ________________________

    Set [Chest] animation frame to 1

    Set Steak position to Chest.Y-30, Chest.X

    ..that works, but if i do like this:

    When [Chest] left clicked

    [Player] X > Chest.X+250

    [Player] Y > Chest.Y+250

    ________________________

    Set [Chest] animation frame to 1

    Set Steak position to Chest.Y-30, Chest.X

    ..it won't work properly.

    I know it sounds pretty weird, i've uploaded my .capx so you can look at it: mediafire.com/download.php

    I just need the player to only access the chest when he is 250 pixels near it. Both on the X and Y axis.

    Thank you,

    • CX05
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Well, as I know;

    player.x should be lesser than chest.x + 250

    and player.x should be higher than chest.x -250

    player.y should be lesser than chest.y + 250

    and player.y should be higher than chest.y - 250

    and for exact calculation you should add or subtract chest.width and chest.height

    Also as I know;

    you can use and invisible sprite where chest is located which has 500 width and 500 height. So you can use, if chest clicked, if player collides with invisible sprite. than open chest.

  • Thank you, i'll try it when i get time.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)