[behavior] rex_interception

Post your work in progress addons and get feedback

Post » Wed Jul 06, 2016 3:49 am

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.
B
108
S
26
G
259
Posts: 4,433
Reputation: 145,689

Post » Wed Jul 06, 2016 7:16 am

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?
B
50
S
23
G
17
Posts: 291
Reputation: 12,432

Post » Wed Jul 06, 2016 8:42 am

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.
B
108
S
26
G
259
Posts: 4,433
Reputation: 145,689

Post » Wed Jul 06, 2016 6:16 pm

Well that was fast :D Seems to be working as I wanted now, I'll check back in if I run into anything else. Thanks!
B
50
S
23
G
17
Posts: 291
Reputation: 12,432

Post » Tue May 09, 2017 7:34 am

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!
B
50
S
23
G
17
Posts: 291
Reputation: 12,432

Post » Tue May 09, 2017 8:00 am

@Sup with that?

This behavior should support official save-load feature. Please provide a very simple capx for your issue.
B
108
S
26
G
259
Posts: 4,433
Reputation: 145,689

Post » Tue May 09, 2017 8:29 am

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?
B
50
S
23
G
17
Posts: 291
Reputation: 12,432

Post » Tue May 09, 2017 9:21 am

Update

Fix bug when "Persist".


@Sup with that?
Please updating this behavior again.
B
108
S
26
G
259
Posts: 4,433
Reputation: 145,689

Post » Wed May 10, 2017 7:49 am

Nice! Looks to be working now, thanks!
B
50
S
23
G
17
Posts: 291
Reputation: 12,432


Return to Work in Progress Addons

Who is online

Users browsing this forum: No registered users and 0 guests