How do I pick an instance once/get family variable <SOLVED>

Get help using Construct 2

Post » Sun Jul 26, 2015 11:02 am

Just two quick issues:
1. - When pressing a key, a boolean toggles the bubble text system. The problem is that if you move closer to other interactive object (they are stored in a family) the bubble will change it´s position too, I would like to pick the closest only once. I´ve been trying it for a while but found no result.

Image

2. - All interactive objects are stored in a family, and each one has a "dialog" instance variable with a line of text (no conversation is intended). No problem when picking closest member to the player, but I´ve searched around and found no way to get the instance variable of the already picked object of the family.

Image

The code´s a mess, though, i´ll try to simplify it meanwhile.
Any help would be greatly appreciated.
Last edited by CloveltOc on Sun Jul 26, 2015 11:55 am, edited 1 time in total.
B
9
S
3
Posts: 152
Reputation: 1,270

Post » Sun Jul 26, 2015 11:14 am

First - you don't need the system every tick condition in event 5 and 6, for they will be evaluated every tick regardless..

Second - you are picking the nearest talk every tick, which is why the bubble moves..

I guess adding an instance variable to the triangle "TalkUID" would do the trick..

add a triangle set "TalkUID" to talk.UID to the on space bar pressed - event

and replace the pick nearest talk condition in the events below to pick talk by comparison : talk.uid = triangle.TalkUID
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 Jul 26, 2015 11:25 am

Works like a charm! Thanks a lot for the quick response, @LittleStain ! But do you have any idea on how to get the dialog variable from a "talk" object? It´s on the second image of my first post, i´ve been wondering for a while but I have absolute no idea on how to approach it!
B
9
S
3
Posts: 152
Reputation: 1,270

Post » Sun Jul 26, 2015 11:39 am

set text to talk.dialogue?
if dialogue is an instance variable of talk this should work..
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 Jul 26, 2015 11:40 am

No, dialog is an instance variable that every "talk" member has, with different text. Is there any way to get that instance variable from the picked object?
B
9
S
3
Posts: 152
Reputation: 1,270

Post » Sun Jul 26, 2015 11:49 am

Yes, like I said..

I'm not sure why you'd say no:

- if dialogue is an instance variable of talk
- dialog is an instance variable that every "talk" member has

If you set the text to talk.dialogue instead of player.dialogue everything should work as intended..
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 Jul 26, 2015 11:54 am

My bad, I created a different "dialog" instance variable for each member individually instead of creating a family instance variable and setting different text for each object.

Thanks inmensely, @LittleStain and I´m really sorry, terribly bad with explanations sometimes...
B
9
S
3
Posts: 152
Reputation: 1,270


Return to How do I....?

Who is online

Users browsing this forum: richardfu and 28 guests