Total weight on an object

Get help using Construct 2

Post » Fri Oct 25, 2013 10:35 pm

Quite a while since a post, I've got an idea but not 100% on how to execute.

How would you calculate the total weight of objects resting on a specific object.

The only way I could think of would be.

look at an object that is overlapping/colliding multiply its density by its size (or have a set variable for the weight).

then loop looking for other items overlapping/colliding that have a location with a Y value > than the last object looked at.

if this value exceeds a certain amount then destroy the original object.


The only issue; I cant see this being massively reliable as the object could then be colliding with two objects (if it was resting on both then i could divide that value by 2, but there would be no way to tell if it is resting the other object with as much force as it is the first)

anyone think of a simpler/more reliable way to do this?
-Id be a nice addition to my release this weekend but not a requirement


Apologies for wall of text

https://www.facebook.com/CritterPopGame
B
10
S
2
G
1
Posts: 77
Reputation: 1,278

Post » Sat Oct 26, 2013 1:18 pm

@JWStudios, Really thinking off the top of my head here. What if you created a loop to apply a force to the bottom of the object you want to test. Keep increasing the force until it moves 1px, in which case stop, or it goes past your threshhold in which case destroy.

Effectively you are just creating a scale. Will not work on immovable object, and dont forget to take into account the weight of the holding object also. Might cause an undesirable 1px shake though.AngelEyes2013-10-26 13:30:13
B
13
S
4
Posts: 67
Reputation: 1,270

Post » Sat Oct 26, 2013 1:59 pm

@angeleyes Appreciated

Nice idea, I hadn't thought about approaching it from that angle!
I'll give it a shot, to prevent the vibration of the critter you could use in invisible sprite setting its location to the critter then applying force to it.

Its quite rare; any moderate too hard collisions will destroy the bad critters and multiple objects falling usually exceed my angular velocity threshold. I've just encountered a couple of times and its bugged me.

Sounds a lot more reliable, it may require a lot of tinkering though. i'll give it a try later & see if we can include this mechanic in the build (finalising the levels atm for the testing team tomorrow and hopefully an android launch!)

I'll let you know!
B
10
S
2
G
1
Posts: 77
Reputation: 1,278

Post » Sat Oct 26, 2013 3:29 pm

You could do something like this - where you've a pinned+invisible detector sprite and counting the number of things overlapping for a rudimentary version.

Until Ashley does an update of box2d and allows some more access to the properties of things through system expressions, or someone makes a 3rd party plug-in, this is what I'd use as a workaround.

http://www.johnnysix.net/games/xmpl/tilter.capx

JohnnySix2013-10-26 15:31:43
Image
B
27
S
9
G
5
Posts: 488
Reputation: 11,948

Post » Sat Oct 26, 2013 10:36 pm

Cheers @Johnnysix appreciated.
B
10
S
2
G
1
Posts: 77
Reputation: 1,278


Return to How do I....?

Who is online

Users browsing this forum: justifun and 6 guests