check if between two objects

Get help using Construct 2

Post » Thu Oct 18, 2012 2:24 pm

so far i've managed to check with a virtual line, but it's not quite there yet since it only checks for the center point of the object between.

i'd love to use the "is between angle of" but it doesn't seem to work that way since i want to check if angle1 is between X of angle2.

I want to be able to check for the whole object, not just the center of it, and i don't want to use an extra object to check for collision (which is what i had been doing)

capx

any ideas?Sargas2012-10-18 14:43:47
B
42
S
11
G
5
Posts: 446
Reputation: 6,417

Post » Thu Oct 18, 2012 4:04 pm

Hmmmm Personally I would stick with the Extra Object with Overlapping Detection..I use them for most of my checks...They function exactly like Raycasting in 3D..
What was the main issue with using a Faux Ray cast object..I think they work fine..
You would only need a single object in that example CapX...

And just check Overlap for each box and update your Variable to show the Object number that is between the two points

The only issue you would have there is if the Ray Cast object overlaps more than a single Block...But I am guessing that you would have the same issues with your Virtual line..

I tried the ray cast and it works fine...Not quite sure why you dont want to use them
Can you elaborate on your Problem?
When in doubt..or you are lost in a Zombie apocalypse or someone is giving you a hard time..Remember one thing..... Read the Construct 2 Manual..it will save your life.:)
B
30
S
11
G
8
Posts: 313
Reputation: 7,360

Post » Thu Oct 18, 2012 7:20 pm

I don't have any problem with the check lines, I've been using them so far.

The virtual line is pretty much the same, but with less objects on the layout and with several less event-lines. My project is quite large (+800 lines) and i'm looking for ways to improve wherever i can.

I manage to make the virtual line, and it works with as many instances as you want too. The only problem i have left is that i can only check for the x&y coordinate, and not for the sprite's shape. But i'm guessing that i can work around that using a custom "coordinate is greater than angle1-5 and less than angle2+5" where 5+5 is the approximate size of the object i'm checking for.
B
42
S
11
G
5
Posts: 446
Reputation: 6,417

Post » Fri Oct 19, 2012 6:17 am

I guess you can use line(segment)-circle intersection, and use circles to represent your objects, it's much easier and faster then with poligons (just define circle size depending on the size of sprite to aproximate spite's shape)...

here are some algorithms(first is simplest and I think it's what you need)

Simple without intersection points

Simple with intersection points

Antoher way with intersection points

Yet Another way with intersection points


edit: line between points is just representational stuff, its all besed on mathpodpathos2012-10-19 06:34:30
B
12
S
2
G
2
Posts: 96
Reputation: 1,583


Return to How do I....?

Who is online

Users browsing this forum: alextro and 0 guests