what does static condition return?

0 favourites
  • 6 posts
  • I was tinkering with my own plugin and I looked at some conditions from the Sprite plugin and some of the code looks kinda odd to me. Specifically in the IsOverlapping and OnCollision condition:

    • why does it sometime return false and the above comment say that "We've already run the event by now." Did the condition failed? If not then what does false mean?
    • sometime it returns "lsol.instances.length". I guess this will traslate into false or true? Same as above I don't understand why the need to return this. Maybe there is some deep unexplained structure here?
    • sometime there is a "runtime.pushCopySol" call which I can't find reference anywhere what it suppose to do.

    I'm trying to do something similar to collision checking with my plugin so I have to wrap my head around these conditions. Any assistance or alternatives would be greatly helpful.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • These conditions have changed significantly in the next build to be a lot simpler, as part of re-working them to support OR blocks. I'd recommend you wait for r88 to be released (out shortly) and check the source again then. 'Is overlapping' is no longer a static condition in r88.

    FWIW, static conditions don't do any picking - basically the runtime will run the function once instead of calling it for each instance, and it's the function's job to do all the necessary picking. It just needs to return true/false, and as per usual javascript if you return an array length or some other number it is true if it is nonzero otherwise false. However, it can be very tricky to get static conditions right, so I wouldn't recommend them. 'On collision' for example uses retriggering to run the event manually which is why it returns false.

  • Thanks for the timely reply :). So as I understand it, return true mean we run this event and return false mean we don't? So what does retriggering do? Does it run the condition all over again or just plain run the action?

    I basically do a ray casting plugin that has condition very similar to 'OnCollision'. What do you suggest I use then (if not static condition)?

  • I doubt you want to use code anything like Sprite's On Collision condition. It's extremely specific to how Sprites work and collide. Can you tell me more about what condition you are trying to make?

  • I'm missing a ray casting plugin that can act like a sentry being able to "see" another object from a distance. If it's just this I could just use a collision box but the catch is the sentry can't see through certain objects.

    So what I do is I cast many rays from the eye of sentry and see if any ray can "see" the subject but is not blocked half way. The angle of view for each sentry can be tweaked as well as number of rays and the length of each rays.

    What I end up with is usually a shape that could be enclosed in a bounding box. And for efficiency, I try to test collision with the bounding box first before I test intersection with each rays. That's why it's very similar to On Collision.

  • Nice rewrite of 'is overlapping'. It seem to me that 'is overlapping' and 'on collision' is so very similar in purpose. Both test for overlap and pretty much pick the same set of instances. Maybe the difference lie in the flow of conditions in an event block?

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