Ruskul's Recent Forum Activity

  • Okay, I found the files I needed. I had them saved in a weird spot. If I had lost all that work I would have deserved an award for worst file management ever.

    If you have any trouble understanding my directions, let me know.

    First, make sure you backup the physics behavior. You can edit it directly if you want but as noted above this presents certain risks. Either way you should make a backup of both the vanilla and edited versions.

    If I recall, the prismatic joint can act wonky if you don't understand how it works so if you are not familiar with it you can check out box2d documentation on it. I kept the names of the parameters the same, so it should make sense.

    In the edittime file you will want to add the following action beneath the others:

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

    //Limited Prismatic joint

    AddAnyTypeParam("This image point", "Name or number of image point on this object to connect object to. Use 0 for the center of gravity and -1 for the object origin.");

    AddObjectParam("Object", "The object to attach.");

    AddNumberParam("Lower translation", "The lower limit of translation allowed, in pixels.");

    AddNumberParam("Upper translation", "The upper limit of translation allowed, in pixels.");

    AddNumberParam("Angle", "The angle to which translation will be constrained to, in degrees");

    AddAction(28, af_none, "Create limited Prismatic joint", "Joints", "Create {my} limited Prismatic joint at image point {0} to {1}, limited from {2} to {3} pixels, at {4} degrees", "Connect another object to a point on this object and limit the range of movement along a particular Axis.", "CreateLimitedPrismaticJoint");

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

    In the runtime file, things are a little less straight forward than kinematics. you need to add the corresponding action: (make sure you add it in the right area, just to keep things tidy. Just scroll down till you find the other Acts.prototype.something.

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

    // Added by Ruskul

    // type 3, takes 5 params

    Acts.prototype.CreateLimitedPrismaticJoint = function (imgpt, obj, lower, upper, angle)

    {

    if (!obj || !this.enabled)

    return;

    var otherinst = obj.getFirstPicked(this.inst);

    if (!otherinst || otherinst == this.inst)

    return;

    if (!otherinst.extra.box2dbody)

    return; // no physics behavior on other object

    this.myCreatedJoints.push({type: 3, params:

    });

    this.doCreateLimitedPrismaticJoint(imgpt, otherinst.uid, lower, upper, angle);

    };

    behinstProto.doCreateLimitedPrismaticJoint = function (imgpt, otherinstuid, lower, upper, angle)

    {

    if (!this.enabled)

    return;

    var otherinst = this.runtime.getObjectByUID(otherinstuid);

    if (!otherinst || otherinst == this.inst || !otherinst.extra.box2dbody)

    return;

    otherinst.extra.box2dbody.c2userdata.joiningMe.add(this.inst);

    var myx = this.getInstImgPointX(imgpt);

    var myy = this.getInstImgPointY(imgpt);

    var jointDef = new b2PrismaticJointDef();

    jointDef.Initialize(this.body, otherinst.extra.box2dbody, getTempVec2a(myx * worldScale, myy * worldScale), getTempVec2b(1,0));

    jointDef.set_lowerTranslation(lower * worldScale);

    jointDef.set_upperTranslation(upper * worldScale);

    //if (lower <= 0 & upper >= 0) // make sure upper and lower don't exceed 0

    jointDef.set_enableLimit(true);

    this.myJoints.push(this.world.CreateJoint(jointDef));

    };

    // /End added by ruskul

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

    Next , in the following function "behinstProto.recreateMyJoints = function()" add an additional case:

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

    // added for ruskuls additions

    case 3:

    this.doCreateLimitedPrismaticJoint(j.params[0], j.params[1], j.params[2], j.params[3], j.params[4]);

    break;

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

    This should be in the switch statement right above default:.

    Now, I didn't provide any expressions or the like for determining if this joint exists, but setting those up shouldn't be to hard. I never needed them so I didn't add them but if you find you do and need some help, let me know.

    Also, there may be bugs. I'm not sure because I never use save game, but I imagine if you try to save the game, this might break. I never use the giant save everything feature in construct and only ever save specific variables to local storage so, again, this hasn't affected me. If this makes a bug for you, I'm pretty sure the fix is easy, and I can probably help you out there if you need it.

    lastly, I named it limited prismatic joint because it goes hand in hand with the limited revolute joint. If there was no limit it could move along the chosen axis indefinitely. The limits simply specify how far it can go in a particular direction before stopping.

    Hopefully this runs for you! Let me know if you get it working!

    Cheers

    -Ruskul

  • - Thanks for the reply, it was a good reminder. I took a moment to look into box2d and I think contruct 2 overwrote my physics behavior at some point in its update. I had it saved as vanilla physics, which probably wasn't very smart. This is no problem though, even if I can't recover the file in dropbox or something I can refigure it out. It just take a bit longer than it should of. I'll be back shortly with an update.

  • - Sorry for the slow response, Ive been at my grandparents house for the last week and now I am catching up with work. When I get a chance I'll dig into that. I ended up abandoning the project in favor of writing my own physics system. If you don't hear back from me in a day or two, give me a shout. I don't mean to, but I'll probably get sidetracked and forget without a reminder at some point. If I recall though, the prismatic joint code was pretty easy (I think). If I can't get the code tonight, I probably can't tomorrow, so it may be this weekend before I can get back to you!

    Cheers,

  • Ruskul I do believe you can split global variables as if they were contained within objects. I can't remember how though.

    Really? I must look for this then. It was one of my biggest quams with using them.

  • Colludium nice, nice, Good to hear.

  • Ashley - that makes sense, but again optimizing the source often destroys that continuity. And yes, obviously it isn't a bug if that is how it was meant to work - I agree with though, I like many I think, thought it was a copy feature -

    On a side note, the separate feature I describe would provide the same benefit it does in its current format but would be a much more useful and robust feature.

    I think plenty others on the forum thought it was a copy paste toll from the work area, not the source. But since we are on the topic.... is this feature planned? Also, how about clearing a tilemap?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • - With a good naming system, it is true... But I would postulate that the better the names the longer it takes to type. In a programing language, these variables would be better split among objects or static singletons that are a snap to access.

    In Construct -

    LevelSpawnPlayerType = something.

    in c#

    level.Spawn.Player.Type = something.

    Autocomplete doesn't work in construct until you get far enough. LevelSpawnPLayerT... if another variable LevelSpawnPlayerLocationX or LevelSpawnEnenmy... or som on exists. In other IDE, splitting the variables up allows you to access them using auto complete which would function at each level of organization. That's the primary reason I stick them in objects as opposed to using globals. Also, the variables clutter up your expressions list every time you start typing in expressions. But if it works for you the way you do things, great, keep it that way!

    I should also point out I suck at typing and the more help I get the better. Too slow! I fail at typing in the same way. lol

  • Kyatric - sometimes its funny how solutions can be so easily overlooked. Its like I'm looking for a complex answer and don't notice the simple stuff sometimes lol. Thanks.

  • The Sprite.pickedCount expression gives that info.

    Well twidle sticks, it would be that easy now wouldn't it

    Thanks for your help, always the champ with the answers.

  • Colludium - Thanks, I was just on your steam page a few hours ago, good to see your making progress. Any luck with the green light?

  • +1 about this^

    I was going to suggest a feature for Construct 3 to have a tab in the debugger that displays the current SOL.

    +10 for that, that would be usefull!

  • Refeuh - Hello,

    Colludium nailed it, The platform behavior is solving the collision as best as it can before you get to even test overlaps. Its not a bug at all and it actually is consistent in what it is doing and why.

    When a collision is resolved in construct 2, there is a certain level of error due to floating point calculations and the type of resolution being performed. If it were guaranteed that collision objects were on a grid pattern and were square, you could calculate resolution perfectly... but as it is there can be up to a 10th of a pixel of error. You can google floating point math errors, and polygon collision detection to get an idea whats going on here.

    On the second badguy, the collision resolution phases of the platformer behavior pushes the player completely out of collisions and then some. It all has to do with how far the object intersected the solid and the type of "push out" that was performed.

    I have had to deal with this a ton in my game, but it isn't a problem that is game ending. You can simply create another animation (OverlapTest) and a frame for your player object that has a collision polygon that is 1 pixel larger than your polygon normally used by the platform behavior. On the rendering side of things, Your player object should be slightly larger than your collision object. This way you get the whole narrow escape but no unfair hits aspect to your game. Let me know if you have any questions regarding this.

    Ashley - I believe this is all correct and similar to something you told me several years ago, please correct me if I am wrong.

Ruskul's avatar

Ruskul

Member since 23 Nov, 2013

Twitter
Ruskul has 2 followers

Trophy Case

  • 11-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • x6
    Coach One of your tutorials has over 1,000 readers
  • Educator One of your tutorials has over 10,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

18/44
How to earn trophies