Having trouble with Physics and Mass

0 favourites
  • 8 posts
From the Asset Store
Simple yet very life-like rag doll made with Physics!
  • I have a 0 gravity setting (space) and have objects of different size and mass colliding. I have set the world gravity to 0, and set different densities to correspond with the size of my objects. When they collide though, it seems to not actually matter. I can have my smallest object with a density of 1, hit my largest object with a density of 80, and given the angle, the large object may start moving in the opposite direction, and the small object not change course at all, or they collide and bounce off each other at the same rate. It seems to be pretty random, as if they do not recognize their density or mass at all.

    Is there something else I am missing? I have 3 objects, I want Object 2 to have 1/2 the mass of object 1, and object 3 to have 1/2 the mass of object 2, and for them to act that way when colliding in space.

  • this is physics man they are random sometimes as i know and u can just calculate them

    example .. object 1 ... density 100 ----- object 2 ... density 50 ----- object 3 ... density 25

    and they will do what they have to do.

  • By changing densities you are changing the mass of each object. If you don't understand basic physics then this could be your error. For box 2d physics:

    Mass = density x area

    If object A has twice the area of object B and then you give it a density that is half of object B, they will both have the same mass.

    Without a capx it's impossible to guess what else might be causing your problem. You can use variables to dig out each object's mass property and check to see if your density guess was correct or not.

  • What I have is say Object A is approx 5-6x the size of Object B, and I set the density to be 4x higher. Yet, sometimes when object A and B collide, Object A will change trajectory, and Object B stays on the same path. Sometimes they bounce off of each other as if they are equal, and sometimes Object B is the one that moves, and Object A keeps going. Sometimes it seems like the angle of impact may have something to do with it (collision points are rather jagged, rather than round) but in any event, I wouldn't think under any circumstance, something with 6x the size and 4x the density should be turned completely around by the smaller object, while they smaller object keeps moving and it's path completely unaltered.

  • My only guess then would be to look at the collision polygon and if you have any forces or impulses set to act on any of them. If you have a capx you can link to it would make this easier...

  • Trying to beat the forum here, I dont have enough rep to post links, string the below together just add in the h t t p

    jmp.sh/b/SmHi8Zi

    OrXIj1g0kglLG

    Just watch a little while, and youll notice what I am talking about.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You're mixing bullet behaviour and physics behaviour... but they are not compatible. The solution will probably be to use just physics behaviour instead.

  • Coll, I ditched the bullet behavior, it did fix my problem, although now I have had to go through and reprogram all of my movements since the set angle and rotate commands are no longer good. So now, I have all my initially spawning objects that you see working somewhat right (I do have them randomized as to where they fly, but it seems like they favor going to the direct center a lot, here is my code for that if you have any suggestions that would work better

    Apply physics impulse 5 towards (random(288,672), random(162,378)

    My center point is 480,270, I think I did like a 40% variance there, but it seems that the variance realistically is much less than that, and favors the center, wondering if there are any suggestions on that.

    My 2nd issue. This is an asteroids based (not replica) space shooter. So asteroid a dies, it spawns 2 asteroid b's. Before with my bullet code, I could set an angle for B based on A, but now, when I try to do similar with impulses, my object B will not move. Here is what I was attempting to use for that

    Apply Impulse 5 at angle objectA.angle+random(-20,20)

    The object does not move, which I don't get since it's applying an impulse, I would think it would atleast move somewhere. Any idea where I am going wrong there?

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