GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

A question I have not seen before.

2 actors. Both are 100x100. Can you use physics to give one more weight than the other? Example: putting them on a balance scale type scenario.

Can you give a group of actors different weights?

Comments

  • SocksSocks London, UK.Posts: 12,822Member
    edited November 2015

    @FINNBOGG said:
    2 actors. Both are 100x100. Can you use physics to give one more weight than the other? Example: putting them on a balance scale type scenario.

    Can you give a group of actors different weights?

    What do you mean by 'weight' in this context ?

    You could use density.

  • FINNBOGGFINNBOGG Posts: 1,810Member

    I guess. some way using 1 actor effects another actor differently than if you use another actor.

    Example: a cannon shooting game. angle and power are the same. but changing a actors weight( density) does more or less damage to a stack of blocks? I guess thats the best example I can choose. I guess Im looking at this more as the user than the coder.

  • RThurmanRThurman Posts: 2,832Member, Sous Chef, PRO

    In box2D (GameSalad's physics engine) "weight" can be thought of as an actor's mass times gravity. w=m*g

    And, in box2D mass is defined as density per square meter. (And I believe a a square meter is defined as 50x50 pixels).

    So a 50x50 actor with a density of 1 will be 'lighter' than the same actor with a density of 1.01.

    But weight really has no meaning without acceleration. (For example, objects in space have no weight even if their mass differs.)

    To 'weigh' two actors, you would need to apply an accelerative force (like gravity) to them.

  • FINNBOGGFINNBOGG Posts: 1,810Member
    edited November 2015

    if it takes more fuel and thrust to move one object than the other (in space) then ones weight is even a factor in space. If i understand you correctly

  • HymloeHymloe Posts: 1,651Member

    I'd like to know more about how to use/affect things in this way, too.

  • RThurmanRThurman Posts: 2,832Member, Sous Chef, PRO

    @FINNBOGG said:
    if it takes more fuel and thrust to move one object than the other (in space) then ones weight is even a factor in space. If i understand you correctly

    Right! Thrust would be an accelerative force.

    Why not give it a try? Make a 50x50 actor and place two copies on a balanced beam. Then apply gravity to the scene. Then give one of the 50x50 actors a little more density and see how it becomes 'heavier'.

    Or in another experiment, accelerate two identical actors (except for density) and see which one is slightly slower.

  • SocksSocks London, UK.Posts: 12,822Member

    @RThurman said:
    Or in another experiment, accelerate two identical actors (except for density) and see which one is slightly slower.

    If you have two identical actors of 50x50 pixels, both set to accelerate downwards at the same speed and with identical physics properties - but one has an image of a feather applied to it and one has an image of some lead, which would reach the bottom of the screen first ?

  • RThurmanRThurman Posts: 2,832Member, Sous Chef, PRO

    The one on the lower layer!

  • FINNBOGGFINNBOGG Posts: 1,810Member

    Haha socks I thought for a split second you were helping me understand something. Then you throw a feather and lead image in the mix.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Posts: 9,913Member

    Density in box2d only affects how objects are forced in a collision or how much energy it takes to move them. In my tests two objects of different densities against gavity travel the same speed. The best way to do this would be to simulate the gravity and vary the acceleration of each object the heavier would have more velocity. I would also use a move behavior as it is based on speed as this would give the object the weight right away as opposed to ramping up over time.

  • RThurmanRThurman Posts: 2,832Member, Sous Chef, PRO

    This might be the case of saying the same thing several different ways. Language is like that sometimes. But I'll try again.

    Weight has no meaning outside of acceleration. Without acceleration, you can have no weight. Einstein proved that even earth's gravity is nothing more than an acceleration around a curve as space/time is warped by large (planet size) bodies.

    But that is weight -- not speed.

    Box2D correctly mimics this fact. You can have two actors with different densities accelerate at the same rate, and they will (surprise) accelerate at the same rate! The same is true of speed. Two objects, with different densities but the same speed will travel (surprise) at the same speed.

    Even two actors thrown out of the leaning tower of pisa will travel at the same speed. (They will also be weightless until they hit the ground.)

    To get 'weight' you need an object that is trying to accelerate against another object that is accelerating at a different (slower) rate. The difference between the two actor's accelerations is a measure of its 'weight'.

    Give it a try in GameSalad. Use it to simulate different bodies with different densities under different circumstances. GameSalad's physics engine will (within reason) correctly mimic newtonian physics.

    The first experiments I would suggest is to make a balance and see if changes in density on two otherwise identical objects make a difference in 'weight'. Then see if they make a difference in speed or even acceleration. The answers should be 'yes' and then 'no' and 'no'.

    This, by the way, is meant to confirm what Dave writes above. To get objects to act as they do on earth (where forces such as gravity and friction can be overwhelming), you should probably use different accelerations on actors that need to mimic different 'weights'. You can also use the move behavior to speed things up. (Or or change velocity.) It wont be correct in terms of newtonian mechanics. But it will be what people have come to expect in game physics.

  • FINNBOGGFINNBOGG Posts: 1,810Member

    I'm waking up in bed. And just read this. I think I came up with a way to experiment. Make a non movable floor. Place a square on the floor directly in the middle of the scene and it's none movable. Give it a round collision take a thin rectangular actor and place it on top of square all 3 actors x directly center of scene. Make 3rd actor movable. Now we have created a scale. And hopefully since all actors are on same X. The movable actor should be balances on the fulcrum of the 2nd actor. Now place 2 actors on both sides equal distance from fulcrum. Give 1 more density than the other. Hit preview. Will this represent a scal with 2 different weights. And if you increase the density of an actor each try. Will it push downward and reach the floor faster. Will speed increase the heavier the actor is from the other.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Posts: 9,913Member

    @RThurman said:
    This might be the case of saying the same thing several different ways. Language is like that sometimes. But I'll try again.

    Weight has no meaning outside of acceleration. Without acceleration, you can have no weight. Einstein proved that even earth's gravity is nothing more than an acceleration around a curve as space/time is warped by large (planet size) bodies.

    But that is weight -- not speed.

    Box2D correctly mimics this fact. You can have two actors with different densities accelerate at the same rate, and they will (surprise) accelerate at the same rate! The same is true of speed. Two objects, with different densities but the same speed will travel (surprise) at the same speed.

    Even two actors thrown out of the leaning tower of pisa will travel at the same speed. (They will also be weightless until they hit the ground.)

    To get 'weight' you need an object that is trying to accelerate against another object that is accelerating at a different (slower) rate. The difference between the two actor's accelerations is a measure of its 'weight'.

    Give it a try in GameSalad. Use it to simulate different bodies with different densities under different circumstances. GameSalad's physics engine will (within reason) correctly mimic newtonian physics.

    The first experiments I would suggest is to make a balance and see if changes in density on two otherwise identical objects make a difference in 'weight'. Then see if they make a difference in speed or even acceleration. The answers should be 'yes' and then 'no' and 'no'.

    This, by the way, is meant to confirm what Dave writes above. To get objects to act as they do on earth (where forces such as gravity and friction can be overwhelming), you should probably use different accelerations on actors that need to mimic different 'weights'. You can also use the move behavior to speed things up. (Or or change velocity.) It wont be correct in terms of newtonian mechanics. But it will be what people have come to expect in game physics.

    You are correct! I totally brain farted this fact. Basic Newtonian physics...duh

  • The_Gamesalad_GuruThe_Gamesalad_Guru Posts: 9,913Member

    A simple fulcrum should do in open space with moveable checked and no check on fixed rotation. Constrain the x and y position and now this fulcrum will rotate on the center axis. Now place two actors on either ends evenly. Since density will work actor to actor, try increased density on one. The fulcrum should push harder on one end. You can use global gravity for this.

  • ArmellineArmelline Posts: 4,800Member, PRO

    A demo of the methods suggested in this thread. For the seesaw, change the density of the two actor instances to experiment with different weights. For the cannon, the weight is controlled by the downwards acceleration, which is currently random.

  • FINNBOGGFINNBOGG Posts: 1,810Member

    Thanks arm. Was wondering I how to incorporate this into an educational point of view for kids.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Posts: 9,913Member

    Just remember density can not he changed at runtime so to change the weight you'll have to spawn new actors.

  • FINNBOGGFINNBOGG Posts: 1,810Member

    So so setting random checker resetting density. Thanks.

  • FINNBOGGFINNBOGG Posts: 1,810Member

    Hey Someone was showing water rolling around in a bottle. Demoing custom polygon collision. What if you made a u shaped pipe. Had water spawn and fill both sides of the pipe with water half way both sides. Then place 2 actors inside each side of the pipe 1 having more density. I wonder if it would push the water and the actor with less density out the opposite side.

Sign In or Register to comment.