Pin phys O's together(lego)OR set img pts/coll.poly by event

0 favourites
  • 7 posts
From the Asset Store
Publish and Subscribe to events in event sheets and from the scripting interface
  • EDIT: I have changed the subject, so I can extend my question, sorry about the abbreviations.

    My question was originally about pinning physics sprites together the way lego cubes are connected; meaning - you can apply force on one or more sprites and the final object behave as one solid object while still has physics properties. The parts would be arranged during the gameplay. I ran into problems solving this either way (PINs, JOINTs).

    But as I was thinking more about the issue, I realized it would have horrible performace consequences even if I make it work. There's where my workaround comes to place (lower in this thread; basically wrap all the square sprites by one invisible sprite with multiple image points and collision polygon). The problem is, it seem impossible to do in C2 which I bought especially for this project.

    I would need to be able to move or set image points within the sprite programatically AND change the collision mask polygon also programatically, i.e. during the gameplay. I can't see the way to achieve that.

    I could premade matrix of 100x100 image points manually and use only some of them, but phew, sounds dull and time consuming. If C2 won't crash on me first.

    I guess changing the collision polygon to trace the borders of all squares during the gameplay will be the same problem as I couldn't find or google the way to change those properties programatically.

    I have also added a simple capx example as requested (see the whole thread).

    Original message:

    (please read to fully understand)

    Canvas:

    2 adjacent physics sprites

    there's a separate force on both of them

    Aim:

    I need to keep them "locked" together like lego parts are.

    Approach:

    • PIN Problem 1: Pinned sprite losing its collision behaviour. Maintaining its relative position no matter the enviroment. Problem 2: If sprite is pinned to movable but sitting sprite, the pinned sprite can't be moved as it's pinned down. I need all the pinned sprites act as one physics object. Imagine lego parts pinned together. No matter which part(s) I apply the force, the whole thing need to act as one object.
    • JOINT Joints doesn't seem to have either of the problems but there's one new. Attached objects collide with enviroment, but don't colide with each other and therefore re-arranging the whole group. I tried to prevent this behaviour to no avail.

    I almost feel like there's no other way to make the physics work as intended, but that seem to me hard to believed.

  • 6 am in the morning, I need to go to sleep, but I think I might have the workaround, one of them anyway. I'll try tomorrow though.

    Make a pin chain out of all the parts and pin the last one to transparent rectangle that would wrap the whole object.

    Then apply several forces from different points of the wrapper sprite to simulate forces on the parts.

    Only thing I need to figure out is to change the collision mask of the wrapper to custom polygon druing the gameplay. I hope that's possible. Still learning my way. I actually start using C2 only today. So I'm sorry if I shot my question too early. I should have slept on that, before running into despair

  • Post a CAPX and I'll give it a shot

  • Post a CAPX and I'll give it a shot

    I like the idea of my workaround, there would be one physics object rather than dozens. Yet I already got stucked just thinking about it. There seem to be no way to set or move image points dynamically during the runtime. So I could hardly apply force simultaneously from different points of one sprite. I haven't tried to googled a dynamical change of collision mask yet, but I'm affraid it will be the same problem as with image points.

    Here's my capx:

    http://saix.cz/mechl01.capx

    IN THE CAPX, there is a force only on left square and a PIN -- right square ignores collision. There's also deactivated JOINT -- but those squares stopped collided with each other.

    Anyway, I don't think any of those two ways are good for performance as the number of connected items will grow. I think I really need to work on that workaround, but I'm not sure it's possible with C2. That would suck, I bought C2 for this particular project.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Like This ?

  • emoaeden I appreciate your help, but that doesn't really work. Only the most left moving part collides with obstacles, the rest just went through. That's what I was trying to solve. I already tried pinning.

    quoting myself from the first post:

    [quote:2ux5l8tu]Problem 1: Pinned sprite losing its collision behaviour. Maintaining its relative position no matter the enviroment.

    + there are other problems with pins as already said.

    Sadly neither joints can't really solve this. Surely not without some serious plugin I'm not aware of. + with dozens or hundereds physics object glued together with joints, there would be huge performance issues I guess. I though about one or two workarounds, but they are far from perfect and often also impossible.

    I'll rather think of other gameplay. I'm not even sure, the final game would be fun. I was aiming for the prototype first, but suprisingly got stucked on technical stuff. I guess C2 can do amazing things, but I chose one of the rare examples which are hard or impossible to do.

  • You could do it still, but making the nearest object the solid one and the rest non-solid.

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