Ok, this is definitely more urgent than other things I’ve asked here. But I need to make a weighing scale for a level
. I think the main problem I have is detecting when and object is TAKEN OFF the weighing scale. To detect if it’s on one side, I just have to tell gdevelop to check if it was put there. But inverting that condition would take it to minus numbers.
So what’s not going well:
Detecting when a gem is being PUT and TAKEN off a side of the scale. Sometimes the number for each side doesn’t increase, sometimes it does
Gems FALLING when one side TILTS UP. The left and right sides are jumpthru platforms so the player can put the gem on it.. although they fall when the platforms move down or up.
Hi. Trigger once doesn’t work as intended inside a repeat event. Are there more than one right side and left side objects? If so you need to use NOT rather than inverted event. You’d be better off with a Boolean object variable for the gem here that is set to true when placed on and false when it’s taken off again rather than using trigger once.
I’m not sure of your methodology. Why are you deducting weight? If you set the weight variables to 0 before the for each object then you would only need to add weights.
Do the gems weigh the same amount? If so, you could multiple the weight of the gem times the number of currently picked gems.
Gem is on platform
Add gem weight times number of gems picked
Yeah , but the deducting weight is for when you remove the gem from that side. Bc the player might want to remove the gem from one side when they put it there.
All them gems weigh the same, except one. But that is made known to gdevlop with a boolean (Heavy) .
I tried removing the inverted conditions and used not, but it didn’t work. It’s still the same sometimes not counting sometimes counting. Infact it stopped reducing the number when a gem was taken off. Also I tried using it without trigger once but the numbers kept adding rapidly
Hi - I did try it the way you were doing it (see screenshots) but when i actually tested it, however using ‘is on a given platform’ condition seemed unreliable to me. So i used point inside object with three points at the base and i got it working but I think a much better way would be to count the instances that are in a collision area using ‘picked instances’ expression. You could have a hidden collision object above each side of the scale.
Also the gems here are platform character objects as I think that’s what you were doing but having lots of these isn’t a great idea really in terms of performance and you could simply apply a force when they’re in the dropped state until they hit the ground.
Ok, ill try this when I’m less busy. Quick question tho… can I still use the ‘Draggable’ feature? Amd also why are you subtracting gems when they are being put on the left side? The weight is actually to be subtracted when they’re being taken off
Ok ..just try taking elements of what I did then. I thought you wanted the scales like old fashioned balance scales where you match the two sides to balance it. I saw you had two sides and assumed that you see. So I’ve done it so that 0 is balanced and -1 is there’s 1 more on the left than on the right. But as I said above I think adding and subtracting from the variable isn’t the best way to do it and it’s better to set the variable to picked instances
Yes, I do want to compare which one is the heavier side. I just didnt understand why taking off from one side would automatically mean im putting it on the other side. The gem could also be dropped on the floor.
Ok .. sorry.I just had one weight variable as I hadn’t noticed you had two. . So yes change your variable for each side or use and object variable scale left.weight
Thank you @petlimpet .. It worked! Just had to do a few adjustments to my system but it actually works now. Exactly how I wanted.
For those who might need this here are the screenshot.. Note
: for the variables “leftweight” or “rightweight” instead of one you can you the weight of each individual gem. Idk ur choice.
Great glad it works. Remember though that trigger once doesn’t work in a repeat event and you shouldn’t need it there if you’re setting the variable from false to true.