Can someone help me understand the physics system a little better?

firemaplegamesfiremaplegames Member Posts: 3,211
edited November -1 in Working with GS (Mac)
Hey,

This is my first time using a real physics system like this. I just faked my way through Danger Cats until I found something that I thought looked okay. I'm just trying to get a more rock solid understanding of it.

It seems that I have 5 major things that I can play with:

In the Scene: Gravity
In the Actor: Density, Friction, and Restitution
And in the Behaviors: Drag

In a blank project, everything starts like this:

Gravity:0
Density:1
Friction:3
Restitution:1

I just want to start with a very simple scene, one actor as a Box, and another actor acting as the Ground. I place the ground at the bottom of the scene, and drag my box into the middle of the scene. i set the ground to not be movable.

The first thing I do is turn on Gravity. It only starts to "feel" right when I set it fairly high, something like 1000. (I finally set Danger Cats to be 500, as 1000 was a little too strong to be fun.)

So my first question is:
What is a good starting initial number to set the Gravity? Just to get normal Earth-like conditions?

So I set Gravity to 1000, now the box drops toward the ground at a "normal looking" speed - And turns into the world's most perfect superball!

Ok, so that bounciness is the restitution, and both the ground and the box have it set to 1, which I understand to be "perfect" bounciness, on a scale of 0-1.

The first thing I do is set the restitution of the ground to be 0, as I don't want it to be bouncy at all. This has no effect. The box still bounces at the same exact height as it did before. Now this brings up a point that Colin made, shouldn't the restitutions be additive? I just removed half of the restitutions from little this scene, and I would expect that the box now would only bounce half as high. And Restitution actually goes up to 2, which would make the box bounce higher and higher each time. a super-superball!

Anyway, so I set the restitution of the box to be 0.1. That seems like an ok starting point.

Next is the Density.
I am assuming that this is where the character's "material" is set. i.e, whether the actor is made of steel, or a feather, or a balloon?
But clearly I am wrong with this, because right now if I change the the density to be 0.1, or 25000, or anything else, it has absolutely NO EFFECT on anything in the scene right now. My box still simply falls to the ground in the exact same way, at the exact same speed. It seems that the Gravity and the actor's density have no relation to each other?

Ok, next is Friction
I assume the friction is only for when two actors are colliding with each other. Setting this to anything currently has no effect on my little scene. Also, what is the relationship between density and friction? if i set the density to be 25000, does the the friction still have the same effect if it is still at 3? in a new actor, density is 1, friction is 3, so if i make the density 25000, would i have to set the friction to 75000 to have the same effect?

Ok, next is the drag behavior.
Initially, it is set to 5. this has no visible effect on my scene. when i set it to 500, now the box moves towards the ground much slower.
but it eventually gets there, it never stops completely. when i set the drag to be 50000, well, now the box bounces up and down all over the place. I have no idea what that means. I thought drag might be similar to "air friction", but i'm not sure.

So my next question is:
How does drag work in regards to the actor's density/friction and the scene's gravity?

Now, i would like to have three boxes in the scene, one is a box made out of solid steel, one out of wood, and one out of paper.
I would like them to fall to the ground at different speeds based on their weight. I would think that just setting their densities would do the trick. But density/gravity don't seem to correlate. It only seems to affect "who pushes who" when they collide.

In Danger Cats, I had helium balloons and bubbles, I achieved this by applying a constant acceleration to them in the UP direction.
To achieve different weights, Do I need to apply different constant accelerations to each of the actors in the DOWN direction?

Essentially, if i have an actor of one type, let's say a box that's 50x50, and I add another actor that is exactly twice his size, 50x100,
I want the larger actor to be twice as "heavy"

I would like to create a seesaw where i would need two smaller actors on one side, and 1 larger actor on the other and have them perfectly balanced.

Also, i realize that this is abstract, but what is the "size" of the scene in the physics system?
is 480x320 pixels a football field? an index card?
if an actor moves from one side of the scene to the other, is that a kilometer? an inch?
I know that doesn't make sense, but i'm trying to get a handle on the scale of the scene
do actors move in pixels-per-second? miles per hour? what does velocity/speed mean in the pixel system.

Also, what "size" is an actor that is 100x100 pixels? a meter?
what is the basic unit of size?

Sorry for the novel I just wrote!

I'm just spewing things off the top of my head. If anyone can answer any of these questions, I would so appreciate it.

Thanks!
Joe

Comments

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    I can't answer much of this as I'm a noob. But, I'm a science teacher. remember that in a vacuum (no air resistance) a penny and a boulder dropped at the same time will travel at the same speed and land at the same time. Sorry, that's all I can answer! I know, not good for much! LOL

    I totally agree with you on the physics being difficult to understand. I would love a clear explanation to these issues as well.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Hey,

    Cool. that helps.

    So, gravity still has an effect on things in a vacuum, it just does not care about their density, right? so it treats a hammer and a feather the same. (they still fall to the ground, just at the same rate)

    So I guess I do need to apply different constant accelerations in the DOWN direction to these objects to simulate different weights?

    I would think that's real processor intensive, though? is there a better way?

    What is the best way to add "air resistance" to the scene?
    So that a heavy steel box WOULD fall faster than a feather...
  • CobraCobra Member Posts: 160
    Density doesn't (and as scitunes says, shouldn't) affect an actor's rate of falling due to gravity. But it does affect how actors move in response to collisions with each other, due to conservation of momentum. Try sending two identical actors smashing into each other, and then try it after changing one actor's size, density, or both.

    GameSalad measures size in pixels and speed in pixels per second - useful measurements since this tells you directly how things will appear on screen, and how they relate to a 480x320-pixel game window. But if you'd prefer to think in inches, or kilometers, or cubits, I can think of no reason why that wouldn't be just fine too. ;)
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Great! Thanks for the help! That answers most of my questions.

    and pixels per second is perfect! that's how I think, anyway...
    coming from the flash world, we had to simulate everything in the old days, before box2d and the like, so i'm used to thinking in pixels.

    So the size of an actor matters as well? That's interesting. I didn't realize that.
    So if I have two actors with the same density, i.e the same "material", and one box is 50x50, and the other one is 100x50, or twice as big - the bigger one will push the smaller one around when colliding? If so, that's cool!

    So my final question is how to make the actors respond to gravity somewhat realistically? If I have a seesaw, lets say, and on the left is a heavy steel box, and on the right are 4 wooden boxes that equal the steel box's weight. if i remove one of the wooden boxes, the seesaw would tip to the left.

    What is the best way to achieve this? Add a downward acceleration to the steel box?

    I appreciate everyone's help!

    Thanks!
    Joe
  • PatronusPatronus Member Posts: 56
    Drag should have the same effect as air resistance. There is a known problem with the drag function in GS whereby it will not bring a character to a complete standstill. I fact, drag brings an object's velocity down to almost zero but it never quite reaches zero. See my previous (frustrated) posts about this. Velocity randomly hops between -1 and +1 for no obvious reason, when an object has drag. I had massive problems with this, in Obstacle Pool, where the pool balls would slowly crawl all over the table when they're supposed to lie still. I think the anomaly that you saw when you tried out the high drag value is related to this. Also, note that a number of actors on the screen using the drag function may cause your program to crash. It took me almost a week of debugging to find that out. I now steer clear of the drag function but perhaps it was fixed in GS 0.6.2?

    To answer your question about the "right" gravity. That depends on your scene. A brick that falls from a skyscraper will take much longer to reach the ground than a cat that falls from a table, for instance. So for close-up scenes you want high a gravity value to make it look real. If your scene consists of, say a bridge that collapses, it will look unnatural if it happens in a flash. In that case you would select a low gravity, to simulate the effect of objects that are far away and that have to fall a long distance. Ever noticed how a building always seems to collapse in slow motion?

    The friction value just controls (to use a real world example) the distance that a box will slide after hitting the ground. If it is zero, the box will act like it landed on ice and keep sliding. At a very higher value it will not slide at all, even if the ground is at an incline.

    I agree that restitution is somewhat odd and I just play round with the values until I find that my actors interact in a realistic manner. Some of the more experienced guys may be able to give you the exact rule that applies.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Hey,

    Cool. interesting point about the gravity and the scene's visual scale. I just opened the "cannon" template and noticed that they had the gravity set to 120, which i thought was really low...but, that scene is very large. i'll investigate the other forces that are in play in that example.

    Science question: does anybody know how density correlates to gravity? For example, in a system where gravity is 500, what would iron's density be? or rubber? or a feather?

    Likewise, what if I change the gravity to 120? Should Iron's density become larger to still "look" right?

    When I create a new actor, the initial density is 1. That seems like such a low number, especially when compared to setting the gravity. should i keep things low when dealing with density? for example, let's say wood is 1, and i set iron to be 2, is that just as effective as if i set wood to be 1000 and iron to be 2000? or do i need to raise and lower the density based on whatever the gravity is set to.

    I just want to have a starting point so i'm not just fudging numbers willy-nilly.

    I appreciate everybody's help and insights.
    Thanks!
    Joe
  • PatronusPatronus Member Posts: 56
    I think what confuses you is that gravity in GS is not based in reality. I think it is linked to acceleration in pixels per second per second. Remember, GS doesn't know what your actors are and how far they are away from you. So whatever type or size your actor, a certain gravity value in GS will bring it from the top of the screen to the bottom in a certain time. No matter whether your scene represents a football field or a suitcase.

    Keep in mind that gravity and density are two different things and their only relation to each other is that gravity pulls down objects, light and heavy, so it creates inertia in them. But that is where it stops. As you now know, an actor with a density of 1 and one of 1000 will fall at the same speed if air resistance is taken out of the picture. However, should the heavy actor come into contact with the light one, the light one will be shot into orbit whereas the heavy one will continue with its original course, largely unaffected. Like a lead ball hitting a polystyrene ball or something.

    I'm not a seasoned GS'er and perhaps some of the other guys will know more about this. But I would play around with the different weights of materials and make a list - not to dictate their downwards acceleration to GS (because we know it has no effect) but to make their interactions with each other realistic. Iron falling on wood may move the wood out of its way whereas wood may simply land on iron without moving it. It may even bounce, unlike iron.
    Let's say you decided that polystyrene weights "1", wood "50" and iron "250" on the GS scale, then you can just as well keep those figures for future reference. By the way, I'm sure you can look the weights of materials up on the internet. Then, if your scene is vast and your actors small, you simply bring gravity down and your actors will retain their relative weights. Likewise, you your scene consists of, say, a kitchen, then you will bring gravity up to compensate for the close-up, fast falling actors.

    I hope it helps.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    hey,

    This answers my question, thank you:

    "Let's say you decided that polystyrene weights "1", wood "50" and iron "250" on the GS scale, then you can just as well keep those figures for future reference. By the way, I'm sure you can look the weights of materials up on the internet. Then, if your scene is vast and your actors small, you simply bring gravity down and your actors will retain their relative weights. Likewise, you your scene consists of, say, a kitchen, then you will bring gravity up to compensate for the close-up, fast falling actors."

    Yeah, it's just for my own reference, just for a starting point. I was just monkeying around with the numbers until I thought they looked ok. I was just looking for a more efficient, scientific way to go about it.

    So my final question, and we can consider this topic closed, is:

    What is the best way to simulate different weights of objects visually(without regard to their colliding with each other).

    Here is my situation:

    I just want four actors in the scene (and the ground, which is unmovable).
    They will not collide with each other, only the ground. They will all just fall straight down. They are all the same pixel dimensions: 50x50.

    I want one to be iron, one to be wood, one to be plastic and one to be polystyrene.
    I want them to fall at different speeds based on their "weight".

    Visually, would the best way to accomplish this be to add different downward accelerations to them?

    Thanks for all your help, i appreciate it.
    Joe
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    I would give them different downward accels if you want them to land at different times, but remember with no air resistance they would all land at the same time.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    ok, cool. thanks!
  • johanclevejohancleve Member Posts: 24
    If you adjust the drag value to a higher number this makes the actor lighter, and so it will fall slower.

    I tried this with two actors with the same size and settings, but I only changed their drag value. And they fall at a different speed.
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    Drag and friction will simulate different weights. For iBMX theres some parts where having the tracks the way i wanted them would add way to much speed for some jumps, so i adjusted the friction in certain parts to slow it down or speed up at certain points. I think thats what you were looking for.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Thanks, guys!

    This is actually the first question I ever asked on these forums...
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    JohnPapiomitis said:
    i was just thinking that , never seen you ask a question Its always the opposite way around haha

Sign In or Register to comment.