Ruskul's Forum Posts

  • Hello,

    I have been going over the sdk as of late ( not the first time) and feel there is a lot of information missing.

    For example, in a plugin or behavior you could include code in tick2 or pretick or even posttick. When are those called? Do I need to use posttickme or pretickme? or do they run automatically? Do I need to un tick them some how when they are destroyed?

    You won't find that in the sdk. You have to figure it out yourself. And there is alot more. Did you know, for example, that in preview.js there are explicit references to certain behaviors (such as solid and shadowcaster). This means that if you want to write attributes like "solid" and have them work with a behavior like platform, then you have to edit the core engine running your game.

    I haven't yet fully read through the relevant code (I would be happy if someone has and can shed some light on this) but it seems to me the way behaviors works is sort of messed up if I need to edit preview.js to really get things working. Every time there is an update I would have to edit it again. Is this really the case????

    I know this isn't a fair comparison, but it took like two days to learn how to code for unity, whereas construct is a pain to code for... I feel like I need to make an auto coder to just add get and set actions, conditions, and expressions for variables... Anyway, I'm off topic...

    The point is that I find the lack of documentation on the sdk somewhat annoying... especially compared to the main manual, which is very comprehensive.

    /rant

  • QuaziGNRLnose Thanks, I didn't think about pin referencing another object. It's funny, this sort of thing is super easy to make in something like unity, but I have so much trouble coding for construct.

  • Hey fellow devs,

    I had a quick question. would it be possible to create a behavior that affects more than just the object tied to it? I want to make a behavior that creates additional objects to function as collision and pickup boxes. I'm tired of setting this up in project after project when it is the same thing.

    The behavior would also affect other behaviors such as physics in post tick.

    I just need to know if a behavior can do this before I start figuring out the hows...

  • Has anyone done some benchmarks for this? How does it compare to box2d web and ams.js?

  • Ashley - when will that be released in construct 2? I'm in no real hurry at the moment but will be exporting a project soon.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Problem Description

    If you change an objects friction via action in the event sheet, and the new friction is different than what it was and it is not 0, the object will freeze position for 1 frame following the change. The position is not updated but velocity and forces are still calculated. The object can be frozen in place via friction changes indefinitely. If any force is being added to the object over time, the moment friction stops being changed, the flies as though it has been in movement the whole time.

    ***Edit - Changing density also causes the same problem! - more on this below /edit***

    The one frame freeze is noticeable at 60fps and extremely noticeable at 40 fps

    Using either box2d web or ams.js makes no difference.

    Attach a Capx

    https://dl.dropboxusercontent.com/u/114 ... oblem.capx

    Description of Capx

    This capx is running a physics simulation with friction set to 0 by default. The ball should bounce around forever as there is no damping and elasticity is set to 100%

    Any frame in which you are pressing space key, the ball object will have its friction set to random(0,1).

    Notice the freeze.

    Steps to Reproduce Bug

    • Step 1 - make a physics object
    • Step 2 - change its friction to a different number than what it was and not 0

    Observed Result

    Objects freeze when changing friction

    Expected Result

    The object should not freeze... >.>

    Affected Browsers

      ALL

    Operating System and Service Pack

    Windows 7 service pack 1, windows 7, windows 8

    Construct 2 Version ID

    190 64 bit and previous versions (I have been aware of the problem since June 2014)

    This bug makes it unreasonable to change friction at runtime in the best of situations. I have checked box2d forums and could not tell if it was a problem with box2d or contruct2 (my hunch is that it is box2d... but I really can't say.

    ***EDIT***

    My hunch is that it is the behavior to blame. It looks like the body is being recreated after setting this.friction. it could be that recreating the body induces a one frame penalty given the way everything updates. Also, Box2d has a built in SetFriction that should be called here, if I am not mistaken. I think you also have to update contacts that are already occurring between the object being changed. Box2d stores the friction in the contact and does not regenerate that information on continued contacts. <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

  • Hey, Is this still the case? I was looking in the "scroll to" behavior and found found that it uses tick2 and not posttick? Am I missing something?

  • mattb - I'm downloading this, looks cool. As stated I probably can't use it in the current project but Maybe the next one I can use it.

  • I am curious, why did you decide to use chipmunk? Was there a defining feature that made it more feasible to add to construct2 than box2d?

    I have been looking through chipmunk and comparing box2d to it. I like all the work you have done, but it seems that some of the features (such as this frame jointing and position setting ) are more a product of how the behavior is written than the physics engine. Is this correct?

  • mattb - Thanks for letting me know about this. I hesitate to switch behaviors at this point in the project I am working on, simply because the switch could be painful. I know all the quirks of box2d at this point (so I say) so I feel it would be better to stay with it. R0j0 is awesome with all his help and knowledge when it comes to physics and math and such.

    Do you know if you can write pre collision events?

  • R0J0hound - as always, helpful as ever. I appreciate the help you have given me and others.

    dax - I got your pm, and I am glad my post was of use to you. I think R0j0Hound has it covered here though. I struggle with math as soon as it gets more complicated than hello world stuff- I get along simply because I get obsessed over it and spend 8 hours trying to figure out why stuff like x = l*sin(a) works.

  • Colludium how do I get c2 to use this older node webkit?

  • Has there been any progress on this in the last month??

    I thought I was going crazy. I have been working on a few big projects and then a while back I started getting jerking. I have been running circles trying to figure out whats wrong... when I started making smaller, very simple games (like here is a red square, move it around the screen with 8 direction behavior) I still get jerks every few seconds. Its just like the op described. Smooth, smooth, jerky, jerk, smooth...etc. The debugger still reports 60 fps at all times!

    It has been a debug nightmare (except I did find a few bugs in my game that caused 1 frame lags, but nothing serious).

  • Wow, Thanks for the reply ASHLEY. Unfortunately, given the nature of your question, this must be a long reply, but I will be as brief as I can. I understand fully the limitations on a small developer team and construct 2 is an exceptional product and I am very happy with it. Just saying ! Thank you for you hard work.

    (TLDR - the platformer behavior is perfect, for a conventional classically implemented platformer. But... my system is better for what I "need"

    Firstly, I understand platforming code can be a bit of a hassle to make. There are so many things to consider and some of the fringe cases can produce glitches that are hard to test for. On the other hand I have already rolled my own collision detection and resolution system a few years ago in XNA – So I do know what I am getting into. I moved to construct 2 due to dev speed and efficiency reasons and occasionally use Unity3d as well.

    In the last year I have been working to force box2d into a flexible platformer system, with variable gravity directions and Jump throughs (funny you should mention those) in addition to a custom particle system that allows 10,000 physics based particles to be present in a layout. I have also tied in my own character state management system (keeping track of arriving, leaving, and being currently on ground, walls, ceiling, and other objects, relative movement directions, and collision states) in addition to managing different projection variables. I have a custom input object that can be tied to character controllers or AI.

    The reason I chose physics over platformer: 1.) Because it is awesome, and I don't think I have ever seen a "TIGHT" 2d platformer that is fully physics enabled. Basically, my game is a platformer with physics... not a physics platformer, if you understand the nuance I am getting at (imagine mario or meatboy or even sonic but with physics). This makes things like bouncing, moving platforms, explosions, elevators, and more, feel very different than in traditional platformers in a very good way. 2.) Because so many small minded people said it was impossible. As it stands I can emulate the original mario perfectly. In box2d. with physics. Small minds = blown. Objective achieved

    Basically, things are going great... I am making a game around this system and I am supposed to be at beta/media ready stage in march... but, as is the norm, I just ran into a large problem in physics (If i want arbitrary changing gravity and slopes in the game)...

    In any frame that I change a friction coefficient to a non 0 number that is different from what it was, then the next frame (when the change is actually applied) the velocity of an object is not added to its position (this occurs in vanilla box2d bundled with construct) This lag in a frame is very noticeable. I cannot abide it.

    Given the way I handle character movement, I need to change friction of characters on a constant basis. Otherwise they interact quite funny when hitting walls and ceilings, but I can't change a wall or ceilings friction because gravity can be different for different things (meaning a ceiling isn't just a ceiling, it is a floor too).

    If I use no friction and handle it myself in context, I need to apply velocity changes based on surface normals. I can create a system in which I know the objects relative gravity, and I know the objects slope based on its family and can work out the normal from there, however this is tedious and it can only allow me to have set angle slopes. It also means I have to make my world with trigger objects that serve to mark slopes. This is also a more inefficient method but necessary because all slopes have to be part of a larger object that has no internal seams (because we can't use chain shapes in construct 2 with box2d)

    Being able to simply pull a surface normal from contact information in box2d would be great. Or, if construct 2 has surface normal information... otherwise I have to develop hacks to get at it.

    I would use platformer except for lack of control in a few key aspects. Firstly, when traveling on slopes, the object does not store the change in vertical movement as a new dy. Thus if you exit a slope into thin air, the object's perceived y velocity = 0 instantly and seems to "pop" from the slope. I understand what is going on here. I know why it does this (I just read through the behavior). Using surface normals, would be a better way of handling this. From a surface normal you could calculate things like friction and restitution. I want my character to slide meaningfully. I also need the character to base its control on the steepness of the slope. Right now in the platformer behavior, the dx remains the same even when running up a steep slope. (again this makes sense for how it is programmed and is a good classic platformer implementation)... but thats not what I want. Also, The platformer behavior in its general usefulness lacks a few features that are not generally useful but are in certain situations (things like collision forgiveness and collision assumptions based on player intent). Mario 3 has this going for it in spades. The collisions are resolved in respect to what a player would most likely want given input and collision context. Further, the jump through behavior works great but not at weird angles and not with gravity switching... If you stand on a steep edge that cant be climbed but is jump through, if you move in the direction of said platform, you go into it.

    Suffice it to say... If I can pull surface normals, then I can fix my system quite easily. I could conceivably make my own system handle physics (I have made a classic platformer behavior using custom movement from within construct 2 events).

    If I can't pull surface normal then I need to probably edit box2d behavior and expose that, as that is probably by best bet at this point in time). I have been holding off on including my edits in my project in hopes that by the time I released they would be officially exposed. I don't want to include some edits, then see a release that includes those edits plus more... due to the whole "behavior/same id / too hard to substitute similar behaviors in a giant project".

    The only thing that has kept me from simply hard coding my own behavior is that it would kinda eliminate the reasons why I use construct 2 over unity. If I have to do that, unity is better situated for that type of dev process (especially given that I more comfortable in c#).

    Does this all make sense?

  • Hello,

    Does anyone know of a way for looking at the collision results from collision polygons from within construct 2?

    I want to roll my own platformer code, but I need to know if I am on an arbitrary angled slope.