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

Get help using Construct 2

Post » Sun Dec 20, 2015 9:10 am

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?
B
27
S
10
G
3
Posts: 612
Reputation: 4,676

Post » Sun Dec 20, 2015 10:43 am

matriax wrote: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?
The Things you can create is only limited by your imagination. If you don't have the skills then use your motivation as a natural force to exceed all expectations. Chadori RebornXD
B
67
S
22
G
90
Posts: 1,125
Reputation: 60,036

Post » Sun Dec 20, 2015 11:04 am

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

When the head of the worm is outside the layout the distance is always 0 ¿?
B
27
S
10
G
3
Posts: 612
Reputation: 4,676

Post » Sun Dec 20, 2015 11:33 am

matriax wrote: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.
The Things you can create is only limited by your imagination. If you don't have the skills then use your motivation as a natural force to exceed all expectations. Chadori RebornXD
B
67
S
22
G
90
Posts: 1,125
Reputation: 60,036

Post » Sun Dec 20, 2015 11:47 am

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.
B
27
S
10
G
3
Posts: 612
Reputation: 4,676

Post » Sun Dec 20, 2015 11:51 am

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
Last edited by LittleStain on Sun Dec 20, 2015 11:57 am, edited 1 time in total.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Dec 20, 2015 11:55 am

LittleStain wrote: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 ;) .

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.
B
27
S
10
G
3
Posts: 612
Reputation: 4,676

Post » Sun Dec 20, 2015 12:01 pm

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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Dec 20, 2015 12:09 pm

LittleStain wrote: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!
B
27
S
10
G
3
Posts: 612
Reputation: 4,676


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 25 guests