How do I get distance working with objects out of layout?

0 favourites
  • 9 posts
From the Asset Store
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • I actually have:

    Distance(enemy_advise.x,enemy_advise.y,enemy_worm_head.x,enemy_worm_head.y)

    The idea is that i'm showing an alert when a enemy is created out of the layout, and an icon advise you. So First the icon is yellow, and my idea is that when the enemy is near(Low distance) change to a red color to give the idea will be appear in the screen inmediately.

    But the distance expresion only works for objects that are in the screen, when the enemy is out of layout the distance is always 0 . I'm doing something wrong? How can i fix it?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I actually have:

    Distance(enemy_advise.x,enemy_advise.y,enemy_worm_head.x,enemy_worm_head.y)

    The idea is that i'm showing an alert when a enemy is created out of the layout, and an icon advise you. So First the icon is yellow, and my idea is that when the enemy is near(Low distance) change to a red color to give the idea will be appear in the screen inmediately.

    But the distance expresion only works for objects that are in the screen, when the enemy is out of layout the distance is always 0 . I'm doing something wrong? How can i fix it?

    Distance can still be calculated even when not on-screen or even outside layout. Maybe there is something that conflicts, do you have a .capx?

  • Here: https://dl.dropboxusercontent.com/u/659 ... tance.capx

    When the head of the worm is outside the layout the distance is always 0 ¿?

  • Here: https://dl.dropboxusercontent.com/u/659 ... tance.capx

    When the head of the worm is outside the layout the distance is always 0 ¿?

    I found the problem, The WormAdviser's position when outside layout is having a hard time updating since it is every tick the worm_advisers position is updated.

    I suggest changing it to Every 0.3 seconds when the Wormhead is outside layout.

    I would fix it but I really have to go. So If I arrived and no one has fixed it yet I will give you a fixed .capx.

  • I see, with 0.3 works, also with 0.1 .

    Other idea is create another sprite, a circle one with 150x150 resolution pined at enemy_advise, and when the enemy overlaps change the animation.

    But well if somebody can fix it correctly using distance and savind add more sprite and events will be great.

  • Well, you have this event:

    Enemy worm head is outside of layout

    set worm advise x - to enemy head x

    set worm advise y - to enemy head y

    So they are at the same spot..

    I always thought two things in the same spot have a distance of 0

    So the text is completely right..

    This should work a lot better

  • Well, you have this event:

    Enemy worm head is outside of layout

    > set worm advise x - to enemy head x

    > set worm advise y - to enemy head y

    So they are at the same spot..

    I always thought two things in the same spot have a distance of 0

    So the text is completely right..

    But you forgot the Advise have a "Bound to layout" so the advise not is spoted at the enemy because he can't move. to the X or Y <img src="{SMILIES_PATH}/icon_e_wink.gif" alt=";)" title="Wink"> .

    If you set ever 0.1, etc... like chadorireborn says, the distance works correct.

    Look this:

    https://dl.dropboxusercontent.com/u/659 ... ance2.capx

    EDIT: I guess is a conflict with "bound to layout" that not left the advise go to the enmy and the distance that seems that to work too fast appears 0. Sure if i get another event instead "bound to layout" that works equals the distance will be fixed. But i don't know how get the same thing in the advise to appeasrs only around the layout without the "bound to layout" behaviour.

  • And without bound to layout even better..

    As you can see I use use the clamp() expression to limit the x and the y position of the object..

  • And without bound to layout even better..

    As you can see I use use the clamp() expression to limit the x and the y position of the object..

    Oh! i see thanks!

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