Items won't "stick"

Discussion and feedback on Construct 2

Post » Fri Jan 08, 2016 12:26 pm

I feel like this is a noob question but I'm not sure why this isn't working.
I'm trying to make items stick to a slot and stay there.
I put the items in a family and made the code:

If Items(family) are overlapping ItemSlot - Set value "ID" of Items to UID of ItemSlot

If ID of Items = UID of ItemSlot - Set position of Items to ItemSlot

Nothing happens when Items overlap the ItemSlots.

Anybody know what's wrong?

Thanks
B
7
S
2
Posts: 45
Reputation: 515

Post » Fri Jan 08, 2016 3:28 pm

It's hard to tell without looking at the events. Can you post a screenshot or a capx? But since you are using variables, using debug you should be able to slowly find the source of your problem. Check to see if the variable for the ID is correct, if they are than it means there is a problem with your action of setting position.
B
36
S
17
G
30
Posts: 679
Reputation: 19,254

Post » Fri Jan 08, 2016 9:51 pm

Sure here's a screenshot

http://imgur.com/DBg07ew
B
7
S
2
Posts: 45
Reputation: 515

Post » Sat Jan 09, 2016 12:10 am

Looks like you're setting ID to the wrong UID. (Items.UID instead of Slot.UID)
B
55
S
28
G
18
Posts: 1,520
Reputation: 25,305

Post » Sat Jan 09, 2016 2:18 am

Oh oops ya you are right. However it still doesn't work even with that fix.

So now it correctly sets the Items ID to the Slot UID.

However the items are not being set to the position of the slots.

Anybody know what's going on?
B
7
S
2
Posts: 45
Reputation: 515

Post » Sat Jan 09, 2016 3:47 am

You should use For Each if there are multiple items (and slots).

so, before event 2, ad -> For each item

Then put event 2 and 3 under it as sub events
Also, ad "pick top instance" Slot for event 2, if an item can overlap more than one slot at the same time

Also, the every tick of the event 3 is redundant.
B
60
S
20
G
4
Posts: 350
Reputation: 6,214

Post » Sat Jan 09, 2016 9:58 am

Hey I tried what you suggested and it still doesn't work. I'm pretty sure the "ID"s are being set correctly, but it's not setting their positions for some reason.
B
7
S
2
Posts: 45
Reputation: 515

Post » Sat Jan 09, 2016 10:48 am

Maako wrote:Hey I tried what you suggested and it still doesn't work. I'm pretty sure the "ID"s are being set correctly, but it's not setting their positions for some reason.



It would be much quicker and save on guesswork if you posted a small. capx highlighting the problem
If your vision so exceeds your ability, then look to something closer.
Moderator
B
126
S
29
G
73
Posts: 5,089
Reputation: 51,998

Post » Sat Jan 09, 2016 4:27 pm

B
7
S
2
Posts: 45
Reputation: 515

Post » Mon Jan 11, 2016 5:53 am

Actually for this example, you don't really need to use the IDs.
https://www.dropbox.com/s/7aogyq2r6ik1w ... .capx?dl=0
B
36
S
17
G
30
Posts: 679
Reputation: 19,254

Next

Return to Construct 2 General

Who is online

Users browsing this forum: jsydik and 7 guests