Total weight on an object

0 favourites
  • 5 posts
From the Asset Store
Cue in the war drums and battle cadences with Total War Game Music Loops!
  • 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

    facebook.com/CritterPopGame

  • 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.

  • 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!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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

    <img src="http://i.imgur.com/DRPUfup.jpg" border="0">

  • Cheers JohnnySix appreciated.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)