[BEHAVIOR] Chipmunk Physics

  • I'm getting the following error:

    Javascript error!
    Error: Assertion failed: Internal Error: Attempting to set body's angle to NaN
    

    localhost/rojoChipmunkBeta_behavior.js, line 52 (col 8)[/code:sxux02kw][/p] [/p] It appears to be related to the 4th action: [i]"gear joint to keep the angle of the plunger the same as the lever"[/i]. When I toggle it disabled, the error goes away. Could my polygon collision shapes be causing an issue with the 0 phase setting?

  • Never mind. I had the lever (plunger) "Prevent rotation" set to yes.

  • Any progress with that parent of 'undefined' error R0J0hound ?

    If necessary, I can try creating an environment where the bug occurs more consistently whenever a collision happens.

  • R0J0hound

    I am deeply enjoying your physics behavior. Thank you!

    I got an issue though. When I am colliding two sprites with the behavior, the one that I control, actually goes into the other sprite. It seems like it doesn't stop at the sprites collision box. Is there a way around this?

    I am using the car behavior on sprite 1. Sprite 1 is being ran into sprite 2, sprite 1 goes inside sprite 2 making it appear unrealistic.

    Thank you!

  • striimix

    Sorry I haven't had a chance to look yet. I've been in a programming slump.

    GameThirsty

    It doesn't really play well with other behaviors. To make it respond realisticly you need to move the object with only the chipmunk behavior.

  • R0J0hound

    Thanks for the heads up R0jo, I guess that happens to all of us sometimes. I could do an "ugly" solution just by pinning impressions over the sprites but then I would need to have a pinned sprite on top of each body part of the ragdoll to later show damaged body parts for example (so it's not really that good option...) Being also a bit of a perfectionist in optimizing things to the extreme, I wouldn't be satisfied by makeshift solution that would clutter things unnecessarily...

    so I'll continue looking into the source, and if I make any progress pinpointing a possible solution I'll post here... luckily the commenting is very good (I'm really impressed with your work... I even was able to get rather good performance on the first iPad when using Chipmunk physics).

    GameThirsty

    Just like R0j0 said, it's best to recreate control logic with chipmunk..if you're mixing several behaviors together, you sooner or later will face situation where the logics are clashing... if you're making a car game, you could make acceleration by tweening a value towards certain velocity, for example) - I would recommend at least completely rethinking what things you need for the game, and defining them.. then think how to do them with chipmunk (it's very diverse).

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This plugin is quite amazing and so far it has delivered a far better experience for my game than Box2D has done.

    1 thing that I think could be implemented though is:

    Condition: Compary Velocity

    Condition: Compare Velocity X

    Condition: Compare Velocity Y

  • SgtConti what do you mean by those conditions?

    If I understood correctly, I think what you're asking for is already in there. You can put that kind of a condition through System: Compare two values.. and then typing YOURSPRITE.Chipmunk.VelocityX / VelocityY.

  • I know, but if you have multiple instances, and you need to pick one specific having that specific velocity, that could be a problem.

    At least I dont know how to do it.

    //Edit: I found the system condition to compare the values while picking an instance. The manual is alway helpful, even after 500+ hours of Construct 2 use

  • Thanks rojo

  • Found a bug (edit: okay nevermind it isn't a bug):

    http://www.filedropper.com/hittinglinebug

    The sprites falling should all turn green, but only one does (because it overlaps the corner??).

    I want to query first hitting line for all the falling objects to know when another object is beneath them. Seems as if this doesn't work as expected.

    edit: on further analysis, it appears that it only triggers when the line is entering the object. It doesn't trigger if the line begins within the object.

    Is there a way to check if a point resides within an object? , then I could use that along with the line check.

    edit2: okay I found a way to solve it. I used two more short lines pointing down at the corners.

  • Is there a way to find the nearest corner of an object? I know there is the nearest point on object event, but that can return points that are between corners. I need a way to get the position of nearest corner/vertex.

  • Prominent

    The best way I can think of would be to create an object at each corner and use the "pick nearest" condition. You'll probably need to define the corners with imagepoints to do that.

  • R0J0hound , ah yea I suppose I could do it that way. I was hoping for something simpler since the objects already have verts to create the shapes. There's no way to access that without editing the plugin or writing my own. I was looking through the runtime and it was a bit confusing, and don't feel like messing with it..

    The sprite already has ability to get x,y of the imagepoints, so I could create imagepoints at every corner and cycle through them checking the distances to find the nearest one, but it gets difficult to manage if objects have different numbers of imagepoints and imagepoints that shouldn't be checked- just thought I'd ask in-case there was something I was overlooking.

    Maybe I'll look at the runtime again and see if I can make sense of it.

  • Or maybe I'll try making my own behavior that checks the polygon in sprites..

    Do you know where that data is kept?

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