Ruskul's Forum Posts

  • Heyo,

    As I understand it, when using the box2d physics behavior, if two objects begin touching each other, the behavior lets the run time know that a collision has occurred. This means that the relevant trigger will fire, causing all oncollision events to run. Without this, it is possible that objects would never be seen by the runtime as colliding because physics would resolve those collisions before you get to ask if they exist.

    Here is the relevant code:

    // For registering collisions

    var listener = new Box2D.JSContactListener();

    listener.BeginContact = function (contactPtr) {

    var contact = Box2D.wrapPointer(contactPtr, Box2D.b2Contact);

    var behA = contact.GetFixtureA().GetBody().c2userdata;

    var behB = contact.GetFixtureB().GetBody().c2userdata;

    runtime.registerCollision(behA.inst, behB.inst);

    };

    listener.EndContact = function () {}; // unused

    But what is missing here is something to let the runtime know if objects are still touching or InTouch. You can't reliably use isOverlapping events with physics without creating extra sensor objects that are slightly larger (since physics resolves most overlaps before you can aks if something is overlapping)

    This can be changed easily. If the runtime is not capable of this, then a condition and expression could be added to the beahvior which could test if contacts were still IsTouching() via their contacts. Either way it would get the job done. This could also be fixed if the runtime had a OnCollisionEnd trigger.

    Simply creating a physics box that lights up when touching other boxes requires compound objects at the moment, which is somewhat wasteful.

  • This bug is a result of cached contacts, and is not really a bug. Box2d does offer a way to get around this caching though. The only way to get around it in more recent versions of box2d (2.1a or later), is to filter it out during presolve. In presolve you can disable the contacts that need to be disabled at run time. Once the objects' AABB are no longer overlapping - which is not the same as isTouching in box2d, the contact will function as expected.

    PreSolve and PostSolve are missing from AMS.JS in the the bindings. Consequently this can only be fixed in box2dweb.

  • Problem Description

    I got a construct 2 check error on trying to close the editor. I clicked close, was prompted to save changes which I did and then I got the popup. It seemed to save everything as far as I could tell, so the only error is the popup saying there is an error.

    I had been inactive for 3 hours before closing.

    Steps to Reproduce Bug

    Unkown.

    Operating System and Service Pack

    windows 7 service pack 1

    Construct 2 Version ID

    R197

    Here is the message:

    ---------------------------

    Construct 2 Check failure

    ---------------------------

    Check failure! This is probably a bug:

    Project still marked as changed after save

    Condition: autosave || !project->IsChanged()

    File: Construct2.cpp

    Line: 2238

    Function: bool __cdecl CConstruct2App::SaveProject(class Project *,bool,bool)

    Build: release 197 (64-bit) checked

    Component: Construct 2 IDE

    (Last Win32 error: 0)

    You are using a 'checked' release of Construct 2, intended for testing, which causes certain errors to be reported this way. Hit Ctrl+C to copy this messagebox - it's useful information for the developers, so please include it with any bug reports! Click 'Abort' to quit (unsaved data will be lost!),'Retry' to turn off messages for this session and continue, or 'Ignore' to continue normally.

    ---------------------------

    Abort Retry Ignore

    ---------------------------

  • BouncyTrip - I hear you there. I use physics to large extent and so am always messing around trying to find the best option I can. I find it weird that there is only a few ports to javascript, despite box2d being so popular. It doesn't give a whole lot of wiggle room if something isn't working so smooth.

  • I posted this in the closed bug forum : https://www.scirra.com/forum/friction-bug-contacts-can-be-updated_t124639 , but I remembered that you don't necessarily check there. So I am putting this here.

    b2body.GetContactList(); isn't meant to return a list but rather a single b2ContactEdge object. you can get the next object in the list (managed by the body) by using .get_next(); However, there is a bug in ams.js that causes .get_next() to always return an object, even at the end of the list. So, you have to use a workaround; Box2d.getPointer( B2ContactEdge ) !==0;

    The following code resets friction across all contacts, and worked fine with the tests I ran.

    In SetFriction:

    for (var contactEdge = this.body.GetContactList();

    Box2D.getPointer(contactEdge) !==0;

    contactEdge = contactEdge.get_next())

    {

    var contact = contactEdge.get_contact();

    if (contact)

    contact.ResetFriction();

    }

    Sorry for the double post if you read the other. I just wanted to make sure you got this! It took way to long to figure out and I didn't want anyone repeating the work if they didn't have to. ... and sorry for not following proper bug posting. I didn't think it was needed here, as it is a known bug.

    relevant post: https://github.com/kripken/box2d.js/issues/17

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ashley - there is a bug in .next(); it never returns null at the end of the list... as a work around box2d.getpointer(contactEdge) !== 0 serves in its place.

    The following Works in everything I did with it. It updates all contacts for the object in question! yay

    for (var contactEdge = this.body.GetContactList();

    Box2D.getPointer(contactEdge) !==0;

    contactEdge = contactEdge.get_next())

    {

    var contact = contactEdge.get_contact();

    if (contact)

    contact.ResetFriction();

    }

  • Ashley

    You might find this useful. As unintuitive as it may seem, b2body.GetContactList(); doesn't return a list of anything. It returns a single b2ContactEdge. The body maintains the list, but you can get to the next b2contactEdge by:

    contactEdge = contactEdge.get_next();

    I have it working to reset friction on more than one contact in my game now.

  • BouncyTrip - yeah, Friction was all set to 0 in both box2d and chipmunk. Thanks though, that's important. That's a pretty sweet hat.

  • Hey,

    Ive been using crappy workarounds to create ropes and what not and I want to know:

    Is there anyway to create joints on objects of the same type to each other?

    For example:

    Object wheel(instance 1) set revolute joint to wheel(instance2).

    Thanks

  • jojoe - do you notice those stutters only in asm.js or is it in box2d web as well?

    Ashley - In your benchmarks, do you use gravity? I am just curious. I like box2d over chipmunk, because it seems more stable to me. I used circles bouncing around and added them manually until cpu was where I wanted it. Now that you mentioned iterations, that is definitely something to consider. chipmunk handled more circles in the test but the physics simulation brokedown (I was losing energy in the spheres over time which isn't right).

  • I am currently teaching programing classes for the local homeschool coop group. I teach beginner classes and advanced classes. The class doesn't focus exclusively on construct 2 but I chose it as a way to introduce kids to concepts in game programing. The kids range in ages from 10-14 .

    Construct 2 is a phenomenal tool, and its speed is what makes it work. I can focus on a specific concept and use built in behaviors to get everything else working. For a bunch of distract-able kids having something working in 10 minutes is super important. It is instant feed back. The only thing you have to worry about is the game code.

    I really appriciate the work that has been done in c2. I love the quick bug fix turn arounds, and honestly, I only complain on the forums as much as I do because I like c2 so much. As far as improvements go, the direction that is being taken with c3 is what is important to me.

    Being able to make behaviors via events, share events easily across projects , more "Object orientedness" (families inheriting from families) and so on.

    On a specific level. I still think c2 needs the ability to insert an image editor side to represent a family. The visual nature of construct 2 is irrelevant in highly abtracted projects using alot of families. You can't see quickly what family you are referring to in the events.

    I would also really love to object oriented style events where we create event sheets and attach them to a specific object, and if that object is a family object then certain groups or methods can be overwritten on objects that inherit. I'm sure you know what I am getting at here. If c3 maintained its quick and easy event editing, but allowed for more complex event descriptions, c3 would be unstoppable. As a user of unity, I could point out that the strength of unity is in the way it handles this. Fast passing of uid is also super important for function calling. If you want to use alot of functions, you end up having to get the uid of the object, pass it to the function, repick the object, and so on every-time you use a function.... which is a lot of work for something that is supposed to make things faster. If I may, there should be an option to maintain the sol when passing control to a function. that way you wouldn't need to do the repicking to get the object or objects in question. If you wanted a fresh sol then you would just check a box. This would be perhaps hard to add, but seriously, please think about it.

    Thanks for listening, as always

  • delaflaquita - that is super interesting. I wouldn't think that it would matter if you exported on intel xdk. Good to know, because I have been using that as of late.

  • So I noticed you have to restart construct to get the engine to change. You can't run a game, change from box2d to ams.js, and then re run it. It will still be whatever was selected on start up. I think.

  • Colludium - thats cool, I like your input. I like everyone's input. I think we have similar wants and desires for physics so it makes sense, lol.

    Those benchmarks are interesting too. For whatever reason, in the test I did chipmunk was outperforming the others (not expected) but had a lower stability. I noticed on your tests chipmunk was not doing so well. I am curious at what would cause this. I was using gravity in my tests with elasticity at 100% to maintain perpetual movement. Friction was also 0.

  • delaflaquita - collision disabling is available as of the r196 and on.