[Solved]Elastic Collision/Kinetic Energy Physics [Bug/Missing Feature?]

0 favourites
  • 9 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Hi there, i been playing for the last 7 days trying to figure out what is the problem with my pool game, why is it so ice like slippery in here.... did someone else experience this?

    the problem can be seen at the rack break when u shoot the pile of the balls first after that there are quirks here and there but overall collision/deflection fail is always present, the balls kinda tend to be attracted to walls even though walls have elasticity set as any normal pool table edge ... is rubery ... but the balls aren't, so in construct physics is missing one key component that is elastic collision ... don't confuse it with elasticity of the object is different, the elastic collision is the force at which the ball reflect upon on impact, where elasticity is the how "fluffy it is" or a secondary state of density which while has some effects on rubbery balls for solid like 8 pool balls makes no sense on having high elasticity mixed with the elastic collision. the balls in construct demo is using the physics circle as collision i can share capx if needed.

    this one is the Construct project where im trying to replicate the pool physics

    Construct html5 pool reconstruction - debugging

    and this is what i want to achieve as pool physics for pool reaction time on impact in construct

    CodeCamp html5 Pool

    notice the difference? or am i the only person seeing it? i feel im going insane trying to "fix" something that isn't even present.

    Ashley or Nepeo sorry for bothering lads, but i snoop a bit in the plugin for Physics of C2, i can't seem to find the kinetic push is using for movement after collision. there is definitely some collision reflection even if i turn all elasticity down and lineardumping to 0, is just it seems to have been corrected to be like a very small fraction if to many objects collide... anyway to fix this issue im having?

    and i followed the collision math in the plugin vs the collision math on the tutorial and they match almost the same minus the extra functions trough which C2physics is working.

    i know this is posted in C3 i tested the same project in C3 running using C3 physics and is still the same result... i looked at the c2 physics cause i don't know where the c3 physics plugin is located we just don't have that type of access anymore... i guess...

  • I'm going to be honest here GeorgeZaharia I know relatively little about Physics engines, they are pretty complex and I've never had to do anything complicated with one. We're embedding a port of Box2D here so my best guess is that your just looking at the properties that Box2D exposes. Ashley will know more, as he wrote the wrapper code for the behaviour, but his answer is probably the same.

    I imagine the reason why you can't see the module in the construct 3 version is that we've swapped from using a JS based port to one done in WASM which is a binary bytecode format. Chrome should still show you a human readable format for the module, but you won't be able to breakpoint it and it will appear as a relatively complex language.

  • I'm going to be honest here GeorgeZaharia I know relatively little about Physics engines, they are pretty complex and I've never had to do anything complicated with one. We're embedding a port of Box2D here so my best guess is that your just looking at the properties that Box2D exposes. Ashley will know more, as he wrote the wrapper code for the behaviour, but his answer is probably the same.

    I imagine the reason why you can't see the module in the construct 3 version is that we've swapped from using a JS based port to one done in WASM which is a binary bytecode format. Chrome should still show you a human readable format for the module, but you won't be able to breakpoint it and it will appear as a relatively complex language.

    I understand now ok makes sense, thanks for taking your time on this issue i was having.

    Maybe this is one of those things to consider in future then for expanding the physics plugin or polish it a bit more, i'll forward it to the ideas/requests sections.

    The bullet behavior has the reflect from object pretty good (as angle reflecting not the power at which it reflects cause it should be equal to half of the initial contact +- spin force but who cares as long as angle is good for reflection) on this issue ... i wonder if maybe that is a possible hint to what might be that physics is missing or is dimmed down cause of gravity set to 0.

  • If tried example and put elastic to maximus, the effect is correct for pool game. Is there something else you looking for?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If tried example and put elastic to maximus, the effect is correct for pool game. Is there something else you looking for?

    i made a lot of tweaks with the elasticity on my capx, and it requires elasticity very close to 1 which is capped at that by default from the physics plugin, but .... what i did different is i changed the density of the ball from being 1 or less than 1 to 50++ u can't do that in the example i shared but while they break in a similar pattern they bounce to much, and that is not what i was looking for the elasticy.

    the example shows the construct version when hitting with cueball the rack of balls pushing the entire rack with the same amount of speed, which in pool that doesn't happen since every ball hits the other ball bouncing back the opposite direction and so on until it stops, however i think im close to find my answer, is not the physics limitation ... is the way i was thinking the powers to be used are capped based on the description they had between 1 and 0 between 0 and 1 and so on... i was thinkin 1 is max... but it turns out for friction and other elements is not... so now is time for fine tuning the right pattern for my balls diameter/collision masks i also seen a very huge difference in buoyancy from circle mask from physics and my own hand made collision mask, which strangely enough is acting much better than the smoother surface, probably cause having corners helps with the ricochet at random angles.

    this is i guess solved, as i said was probably limiting the math/physics of object size and how much weight they should have with the actual elasticity ....

    so the solution is u can go 1 elasticity but make sure u do density double your balls diameter 2 x diameter * pi friction, 1/pi*2 linear damping and angular damping linear damping and angular damping equal to linear damping always since we don't have a Z rotation of the ball. and walls need match balls -90% elasticity drawn back

    my bad, sorry for exaggerating Nepeo thanks once more for taking your time with me ...

  • I think your example is good enough, so I would not worry about it too much. Just polish it up and finish the game.

    All physics engines, although they help, have things missing. One of the most annoying things with box2D is if something moves too fast it will go through objects.

    Guess what happened the first time I used physics in Unity and threw a soccer ball a little faster. It went straight through the net and through ad boards behind the goal. If you ask a question about this, you will get an answer along the lines of: "you have to use raycasting, bla, bla, bla, code it yourself"

    Shouldn't that already be a part of the ^%$9ing physics engine, yeah it should, but look at the bright side, at least it allows you not to have to code all the other parts that actually do work.

  • I think your example is good enough, so I would not worry about it too much. Just polish it up and finish the game.

    All physics engines, although they help, have things missing. One of the most annoying things with box2D is if something moves too fast it will go through objects.

    Guess what happened the first time I used physics in Unity and threw a soccer ball a little faster. It went straight through the net and through ad boards behind the goal. If you ask a question about this, you will get an answer along the lines of: "you have to use raycasting, bla, bla, bla, code it yourself"

    Shouldn't that already be a part of the ^%$9ing physics engine, yeah it should, but look at the bright side, at least it allows you not to have to code all the other parts that actually do work.

    that speed glitch happens on objects that has is bullet not selected once u tick that u can blast them at really high speed. if u compare the rack smashing in the beginning of both games i linked, the seconds one spreads all balls in a nice little pattern as physics makes sense there from collisions that happen, in my version after first impact all balls move the same direction doesn't matter what is the elasticity weight speed etc. however i found a sort of a solution but its still not fixing it, but is a bit better. anyway ty for input, but i didn't wanted to make another sliding ice hokey game.

    i ended up making the pool game using Q3D in the end. the physics in Q3d react as they should it might be cause of the gravity on Z axis that pulls the balls down and give them extra elastic power and friction+inertia and takes ball spin in calculation also, anyway, i was trying to create a 3d roll i think with a 2d physics and that probably isn't gonna happen unless i tweak the plugin itself. which would be much easier to just make the physics i need by using Construct events.

  • There’s this old topic that may be relevant. It has a way to do 2d physics for pool. It improves on the collisions by finding collisions when the balls just touch instead of counting the first time it overlaps as a collision. My method was slow at converging on a solution at times.

    construct.net/en/forum/construct-2/general-discussion-17/approaching-pool-ball-movement-56649

    It can be made more precise by just calculating when two balls hit. I think the above moves the balls as normal and once any of them overlap all the balls are moved back a bit at a time till they are just not overlapping, and then doing the bounce calculation.

  • It can be made more precise by just calculating when two balls hit. I think the above moves the balls as normal and once any of them overlap all the balls are moved back a bit at a time till they are just not overlapping, and then doing the bounce calculation.

    I searched the forum so much for pool related keywords but for some reason that did not pop up. I got a elastic collision thread that helped a lot with the math of velocity after impact, and other pool stuff related where just bleah.

    Thank you R0J0hound il try it out, i have made so far, the balls bounce of walls, that was pretty easy, now i was actually stuck at individual collisions of instances of the same object type, this should help me, as it sounds it is very similar to the way i was trying to make my physics, i actually already have a on collision loop but i was stuck at angle/power(finding the normal and tangent and applying the proper recoil power) after collision, il definitely try both files shared in that forum area.

    Thank you once again.

    I think if this works good, il try make it into a plugin+behavior cause the pool physics im trying to do are not the same as with the default Construct physics no matter how much elasticity you give them they just don't go there by default and a few variable adjustments.

    Especially when a ball using the Construct physics touches a "wall" at small speed, instead of bouncing off it by a small energy factor it just slides along the wall... and that is a pain to fix ...

    Edited:

    I seen your capx with events made physics that is awesome, exactly what i was saying.

    I thought im going crazy for a while now.

    BadMario i did actually made my own raycast lol ... from events. I needed one for the guideline of the pool game, now i have all the pieces i need to make a pool game, and not a hockey sliding game lol. Il share a capx and demo once i finish (even though the link r0j0 sent is pretty straight forward).

    R0J0houndI tweaked a few variables added friction and impulses based on cue hits and it's amazing, now that feels like an actual pool physics. +Infinity Likes and Love man. Il study this in depth, this is amazing, didn't knew we can use the While loop like that.

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