How do I prevent a physics object from tripping?

0 favourites
  • 15 posts
From the Asset Store
Simple yet very life-like rag doll made with Physics!
  • My game is behaving weirdly. I have a Physics object P which moves left and right by applying force. When moving on a line of crates O (illustrated below) P intermittently 'trips', causing it to rotate a little and losing VelocityX, sometimes to a total stop.

    All the Os are Immoveable. Friction and Linear Damping set to 0. P's Friction and Linear Damping are also 0.

    Any ideas what could be causing this?

    P

    OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO

  • Beveling the corners of the objects or merging together objects in a row would help fix it.

    It seems to be a general issue with physics engines.

  • Hi R0J0hound, thanks for the suggestions. I tried beveling the corners of the crates, didn't help.

    Weirdly, one of my 5 players characters was not tripping. I managed to solve the issue by cloning that working character into others. But this seems more like a workaround than an actual solution.

    Any other ideas?

  • Have you tried enabling "Prevent rotation" in physics properties for that object?

  • dop2000, I did. It causes the player character to come to a full stop.

  • It's difficult to speculate what could be wrong without seeing the actual project. You can try helping the object to slide better by applying a small force to the front of it, directed upward.

    Also, enable "Show collision polygons" in layout properties, and check "Collision mask" property for physics objects.

  • If the crates are immovable make them a single long sprite instead of separate crates ( In photoshop or some other program copy and paste crates into a row until it looks exactly the same as it does in your game, then export that single png.

    You will have just one collision polygon instead of many smaller ones. I think what is happenning in your game is that your object hits crate edges and that causes it to lose speed. With one single polygon this should be eliminated

  • dop2000 Tried applying a force upwards but still the same. I'll share the capx soon.

    BadMario I can't do that because the intention is for each of the crates to be destroyable. If they are all stretched on in a single img, then the game mechanics won't work.

  • Hey All,

    I have uploaded a sample to demonstrate the problem.

    drive.google.com/file/d/1sGHGleCBfJGgOb-V3vd9B2Er77LXsOsw/view

    Use the left and right arrow keys to move the character. You can see that the surface of the crate is uneven and there are bumps as the character moves along it.

    In my full game the characters get stopped on their tracks upon meeting these bumps.

    Thanks!

  • You should mention that you are using Construct 2, because the solution may be quite different from C3.

    For some reason you have rectangular collision mask for the bird, and circular for crates. Shouldn't it be the other way around?

    After I changed the collision masks, the bird slides fine for me. It bounces up a little bit sometimes, but its horizontal velocity remains constant.

  • Sorry, this must have my biggest blunder this week, I didn't notice this was in the Construct 3 sub forum!

    Mods, can you move this to the Construct 2 sub forum please?

    dop2000 I have removed the plugin, thanks a lot!

    drive.google.com/file/d/1EjsfEQJbfs79471NooPdOC6bjV8vyYYP/view

  • To add to my previous comment - the reason why other character were tripping was probably some minor differences in their animations. If one frame is just 1px bigger or smaller, or the origin point is misplaced, this could cause such problems.

    When using animated sprites, make sure that origin points and collision polygons are identical in all frames. Or create a separate (invisible) sprite, with just one frame, which will act as a character base with Physics behavior, and pin your animated sprite to it.

  • dop2000 Changing my characters to a circle collision mask while keeping the crate's to collision polygon did solve the issue although the characters' movement got a little bouncy.

    I still don't understand why one of the characters which has a square collision polygon glides through the crates - no bounce, no sudden stopping whatsoever. I have even made another character to have the same size, same animation, same collision polygon, same points and still it wouldn't work. It'll only work if I clone it.

    Anyway this ordeal taught me a lot about the physics engine, thanks a lot!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Moved to the C2 forum as requested.

  • BadMario I can't do that because the intention is for each of the crates to be destroyable. If they are all stretched on in a single img, then the game mechanics won't work.

    It can work, make it an invisible physics object, then put box sprites on top of that. Boxes don't even need physics, just destroy them on collision

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