collision of line object

For questions about using Classic.

Post » Fri Jan 15, 2010 3:26 pm

Hi Folks,

I have to movable objects, between them I have a line-onject. What I want is that another object, touching this line (like a laser) gets hurt. What I GET, is a collision between the bounding box of the line and the object. That means, if the line is not perfectly horizontal or Vertical, collision happens in an area which is not only the line, but a rectangle around the line.

Anyone has an idea how I could solve this problem? I don't want anyone to code me anything, just a tip on the best manner to solve this problem.

Thanks

Maenny
B
2
G
3
Posts: 16
Reputation: 882

Post » Fri Jan 15, 2010 6:19 pm

Actually I don't think they planned on having collision detection on the line object, might be nice tho....
In the mean time the quickest way would probably be to use a dummy sprite set between the two objects.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Fri Jan 15, 2010 6:51 pm

[quote="newt":2o469rnr]Actually I don't think they planned on having collision detection on the line object[/quote:2o469rnr]

Yeah, this was my understanding as well. The line object was made to just have a quick and cheap way to draw a line, with no frills. Kind of like how the particle object is a quick and cheap way to draw a bunch of little sprites flying everywhere. No collision intended.

You could try using a Bullet Behavior object set to instant-hit in conjunction with your line object. I've seen that method used for lasers before.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Fri Jan 15, 2010 7:48 pm

Deadeye is... dead on. It was a quick plugin to draw lines. Intersecting lines with pixel-perfect masks in our current collision engine would be kind of tricky and take a while to code - and it's a bit of a corner case anyway. The accepted way to do lines before the Line object was a wide, narrow sprite with the hotspot at the middle left. Then you set its position to the start of the line, set its width to distance(startx, starty, endx, endy), and set its angle to angle(startx, starty, endx, endy). Bingo, sprite line with collisions.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,528

Post » Sat Jan 16, 2010 2:37 pm

Hi,

Well, that's exactly how I decided now to do it. Thanks for the help again.

Maenny
B
2
G
3
Posts: 16
Reputation: 882

Post » Wed Jan 18, 2012 6:46 pm

woah, ashley how would i go around adding two hotspots on an object, one left and 1 on the right. i want to be able to hold the mouse down and drag out an object, the hotspot idea should work
B
10
S
1
Posts: 39
Reputation: 1,053

Post » Wed Jan 18, 2012 7:32 pm

Why doesent it have an icon?
B
18
S
4
G
1
Posts: 413
Reputation: 2,512

Post » Wed Jan 18, 2012 7:46 pm

@LukeMarkBrady You don't need two hotspots. hotspot 1 for the origin point, and from there you set the width to the distance from the origin point to the mouse[distance(values in here)], and the angle from the origin point to the mouse[angle(values in here)].
B
9
S
2
G
4
Posts: 346
Reputation: 2,726

Post » Wed Jan 18, 2012 11:22 pm

@Steven ok, i understand what your saying, however still a bit confused and new to construct, any further guidance you could give?
B
10
S
1
Posts: 39
Reputation: 1,053

Post » Thu Jan 19, 2012 1:35 am

@LukeMarkBrady Here is an example of what I was saying.

http://dl.dropbox.com/u/1487524/Scirra/LineExample.cap
B
9
S
2
G
4
Posts: 346
Reputation: 2,726

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 7 guests