compound object

0 favourites
  • 15 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • 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...

  • You can acess the instance the behaviour is tied to with this.inst i think. If you have refrences to those other objects (for instance through uid, or just from some js ref, or previously stored through some picking condition) theres no reason you cant code the behaviour to affect both. I think pin behaviour does this sort of thing. You can create new objects with runtime.createinstance or something like that, then store refs to those in the behaviour, and do as you please with them.

  • 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.

  • Its not really hard, just different.

  • QuaziGNRLnose - It turns out, Ashely said that is a very bad idea... I'm not sure why, just that construct 2 wasn't designed that way. Basically, calling a condition or action of another behavior (even on the same object) from a second behavior doesn't work. I asked for clarification but haven't heard back... I can't even find/remember what post it was in

  • reuse ACE

  • rexrainbow - Oh my goodness, where have you been my whole life! this website is a gold mine!

    So then, nothing bad happens when you call a behaviors action and don't use the event sheet to call it?

    ...and it works with a behavior and not just a plugin?

  • Ruskul

    Most of ACE reusing had no side effect, but I could not promise for all cases.

    And yes, it works with behavior and plugin.

  • rexrainbow - I noticed that on your blog the zip file for pid tourque was broken. I also could not find it on the forums here. Is it that supposed to be the case?

    It seemed to be doing something similar to what I wanted but I couldn't open it/ unzip it

  • rexrainbow - Thanks for your help!

    I can't seem to be able to get a plugin call to work, though: It always returns NaN...

    //Runtime

    Acts.prototype.SetX = function (tilemap, zX)

    {

    cr.plugins_.Tilemap.prototype.Exps.PositionToTileX.call(tilemap , fake_ret , zX);

    this.testing = fake_ret.value;

    };

    //edittime

    AddObjectParam("TileMap", "Set the tilemap");

    AddNumberParam("X", "X");

    AddAction(6, af_none, "Get tilemap x ", "", "gets test x", "No Description", "SetX");

  • tilemap in "Acts.prototype.SetX = function (tilemap, zX)" is an "object type", not an "object instance".

    the first parameter of "cr.plugins_.Tilemap.prototype.Exps.PositionToTileX.call(tilemap , fake_ret , zX);" should be "object instance".

    So you could try

    Acts.prototype.SetX = function (tilemap, zX)

    {

    var tilemap_inst = tilemap.getFirstPicked();

    cr.plugins_.Tilemap.prototype.Exps.PositionToTileX.call(tilemap_inst , fake_ret , zX);

    this.testing = fake_ret.value;

    };

  • rexrainbow - very nice! I came up with the same solution last night. Thank you for your help, and thanks again for posting stuff on Endless Loop. It is super handy.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • rexrainbow - oh no! I tried to access the links you provided ad they are down (angular torque).

    I'm currently trying to figure out how to access another object's behavior (I'm trying to make it so I can have a behavior access itself on another object for an inventory system)

    is it something like this:

    cr.behaviors_.Custom.prototype.acts.ActionName.call(someother.inst, i, j);

  • Ruskul

    The someother.inst is "the instance of the behavio"in inst.behavior_insts array, see this sample.

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