collision of line object

This forum is currently in read-only mode.
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • 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.



  • 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.

  • Actually I don't think they planned on having collision detection on the line object

    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.

  • 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.

  • Hi,

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


  • 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

  • Why doesent it have an icon?

  • 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)].

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Steven ok, i understand what your saying, however still a bit confused and new to construct, any further guidance you could give?

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

  • any chance of another link. this one doesnt work =/

  • LukeMarkBrady

    Link is fine. Just copy and paste into browser.

  • i got it, i was using 2.0 lol. your right, that is the kind of thing i want, but the base is set in one place, i would need it so i choose where the base of the line will be by holding the mouse down, and dragging out the line like it does in the .cap

  • In cc r2, a new collision type makes it so line collisions work as expected

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