[behavior] rex_interception

0 favourites
  • 9 posts
  • Predict the point of intersection. It assumes that objects move with constant speed.

    See this demo first

    Document, plugin and sample capx file are included.

    This behavior will NOT change the position of instance, it only provides predicted position.

  • Hey so I'm trying to use this plugin to make homing missiles and I've run into a problem which I can't seem to get around. I have several Enemy instances and an equal amount of Missile objects. Each Enemy shares a unique value with one Missile, and the game then tries to use this to make sure each Missile goes after only one Enemy (the one that shares the unique value). The problem occurs when I try to use the PredictX/Y expressions.

    Can't post image from imgur so here's a link.

    • In the bottom example everything works as intended - each missile goes after its own individual target. So up to this point it's fine.
    • However, in the top example using Predict instead of default XY position, all missiles go after one, same target.

    I tried a few expressions like For Each Missile/Enemy and things like that, but just can't seem to get around this. Is there some way to fix it?

  • Update

    Add "Action:Lock by UID", "Expression:TargetUID", and show target UID in debug panel.

    Sup with that?

    Here is a sample capx which has 2 homing missiles and 2 targets.

    You might check the target UID first in debug panel.

  • Well that was fast Seems to be working as I wanted now, I'll check back in if I run into anything else. Thanks!

  • Hey, me again with another issue to report: this behavior doesn't seem to be supported by Scirra's Persist behavior. Switching layout causes objects to lose their lock.

    Quick workaround (if using Lock by UID) is to have the target UID saved in a variable and re-lock on start of layout, but I just figured it'd be nice to have it supported by Persist if possible. Cheers!

  • Sup with that?

    This behavior should support official save-load feature. Please provide a very simple capx for your issue.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I hope this capx illustrates it best

    https://www.dropbox.com/s/nyj4ka0uyuzew4n/interception-layout.capx?dl=0

    Clicking one of the green spots makes the blue arrow lock to it. When locking blue arrow will always turn towards sprite that it's locked to. After switching to layout 2 and then back to layout 1, blue arrow no longer turns towards the sprite it was locked to. It seems lock is lost despite having Persist behavior?

  • Update

    Fix bug when "Persist".

    Sup with that?

    Please updating this behavior again.

  • Nice! Looks to be working now, thanks!

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