Weight scale-style platform

Get help using Construct 2

Post » Sun Aug 16, 2015 12:15 pm

I'm trying to implement a weight scale-style platform in my game where when enough "weight" is on the platform it will go down, otherwise it will go back up. I'm not looking to mix physics behavior (or realistic life-like physics) in this project so I'd preferably like to find a way to set this up differently. To be more clear, what I want is just a platform that will go down if 3 boxes or player and 2 boxes are over the platform. I would need it to also work in cases when boxes are piled up over one another on the platform or when player is standing on a box that is on the platform, as long as the needed "weight" to move the platform is reached.

I have a hard time figuring out the event logic to make this happen. I've tried using hitbox and instances to add/substract from the weight but can't get it to work as I'd like. I'm not sure what would be the best way to get the platform to react also in case the weight is piled up over one another and not standing directly on the platform. Is this even practical to try without physics or is it just better to try and go with physics instead? I've had some problems with mixing physics and platforming behaviors in the past so I'm hesitant to use it unless I have no choice.

Anyone have any advice on how this could be implemented? I'm a bit stuck at the moment and thankful for any possible help!
B
38
S
12
G
5
Posts: 151
Reputation: 5,338

Post » Sun Aug 16, 2015 12:31 pm

It certainly can be done without physics. I would probably use a "detector" sprite - an invisible sprite above (and pinned) to the scale platform. When enough boxes and/or the player are colliding with it, then lower it.
B
99
S
35
G
20
Posts: 438
Reputation: 17,910

Post » Sun Aug 16, 2015 1:05 pm

Exactly like AllanR said: You could make an invisible trigger box on the "scale" and when three boxes is overlapping the trigger on the scale it goes up/down.
B
58
S
25
G
14
Posts: 793
Reputation: 13,302

Post » Sun Aug 16, 2015 3:27 pm

Thanks for the quick reply! That's how I've tried to do it, I have a triggerbox1 pinned to the lift platform to count the objects overlapping it (to add as weight) and triggerbox2 to the side to prevent the objects interlapping only barely with the lift and still counting towards the weight.

This is working so far as it should, counter adds the weight when objects overlap with triggerbox1 only and substracts weight when not, but problems arise if there's an object next to the lift and other objects are stacked over it, as demonstrated by this mockup picture:

Image

As the upper objects are overlapping with triggerbox1 only, they still add to the weight counter, even when in reality their weight is not on the lift platform at all. I probably need an instance value for boxes to state whether they're standing on the lift or not or something. Not sure yet how to approach it, but if any suggestions come to mind as to how to fix this I would be very happy to hear about them:)
B
38
S
12
G
5
Posts: 151
Reputation: 5,338

Post » Sun Aug 16, 2015 6:15 pm

@Waltuo

I would create a family for stuff that can go on the scale (boxes and player) and add an instance variable called something like ExcludeFromScale (and possibly one called Weight if you wanted different size boxes or other items and need a specific weight to lower the platform). Anything overlapping the Prevent box would get flagged as ExcludeFromScale, and anything resting on top of an excluded object would then also get marked as excluded.

So, to test objects overlapping the allow area (and not already excluded by overlapping the prevent area), I would do a For Each (oredered) scalefamily order by scalefamily.Y descending (that would start at the bottom and work to the top) and test to see if the object they are on is excluded.
B
99
S
35
G
20
Posts: 438
Reputation: 17,910

Post » Fri Mar 24, 2017 5:52 am

Do you finally implement a weight scale style platform in your game?
B
3
Posts: 2
Reputation: 179


Return to How do I....?

Who is online

Users browsing this forum: angryscientist, DarthPapalo666 and 23 guests