Distance not working

Get help using Construct 2

Post » Tue Mar 13, 2012 3:02 am

I wasn't sure if this was a bug or if I've made an error.

I'm using the Compare Distance parameter, and everything looks fine to me, but it's not working.

Here's the capx

And he's the test of it not working: Test Game

Here's what my event looks like:




Basically, when the "locked" door is approached, I'd like the text to display.
B
7
S
1
Posts: 24
Reputation: 935

Post » Tue Mar 13, 2012 1:26 pm

There's several issues with your capx :
1/ you can't really know if the event is working, because your text is way out of screen at (70,446) when your character (an then the scrolling) is at about (880,3200). So you need to put your text and text_box in another layer with 0,0 parallaxe
2/ 10px is too short, your the distance between the hotspot of your character and it's boundaries are already greater than 10px.
I put < 60 instead
3/ the system distance() function doesn't do any picking. If you know you'll have only one closed door in all your layout it's ok. But if you want to put more than one, you have to filter each closed door with a foreach and do the distance check afterward.

Look at the capx. the order of event 23's conditions is important:
- first filter closed door
- next take each closed door one by one
- and then do the distance check on the door the foreach is on

doorPicking.capx
Last edited by Yann on Sun Sep 14, 2014 9:19 pm, edited 2 times in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Tue Mar 13, 2012 9:34 pm

[QUOTE=Yann] There's several issues with your capx :
1/ you can't really know if the event is working, because your text is way out of screen at (70,446) when your character (an then the scrolling) is at about (880,3200). So you need to put your text and text_box in another layer with 0,0 parallaxe
2/ 10px is too short, your the distance between the hotspot of your character and it's boundaries are already greater than 10px.
I put < 60 instead
3/ the system distance() function doesn't do any picking. If you know you'll have only one closed door in all your layout it's ok. But if you want to put more than one, you have to filter each closed door with a foreach and do the distance check afterward.

Look at the capx. the order of event 23's conditions is important:
- first filter closed door
- next take each closed door one by one
- and then do the distance check on the door the foreach is on

http://dl.dropbox.com/u/23551572/C2/doorPicking.capx[/QUOTE]
1) Ah, you're right. Silly mistake ><. I've got it set up correctly in my project file, just not in the capx test file I linked too.

2) Good to know! Thanks.

3) Also good to know, I'll give it all a try. However, I want all closed doors to behave the same anyway, so isn't this potentially a non-issue? At any rate I've give it a try with the fixes you've suggested.

Thanks again, I'll try it myself and let you know how it works out :)

Oh, and thanks for the fixed capx, works perfect! breravin2012-03-13 21:37:24
B
7
S
1
Posts: 24
Reputation: 935

Post » Tue Mar 13, 2012 10:13 pm

If you don't use the foreach, the distance check will be with the first instance of the Door. So for the second the check will return false and then the text will never appear.
So yeah you'll need the foreach if you have more than one door even if the associated action is the same.

You're welcome.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Calfuso, totoe and 22 guests