Beam Weapon Collision Detection

This forum is currently in read-only mode.
From the Asset Store
Detects any kind of ad blocker. Very easy implementation into already existing projects
  • Hey, I'm making a beam weapon and it's length needs to be rather long 10000+ pixles.

    And it's needs to cut down it's length if it hits an object.

    I can do this: collision with blah blah: set width to distance(x1, x2, y1, y2) etc.

    The problem is when it is a near miss the frame rate chugs down to less than 1! I know, my laptop, not a gaming machine.

    But I was wondering if there was any better way to do it. Angle detection or something. Any ideas?

  • I don't understand why, but this makes my uber-rig cry (I get down to less than 1fps as well)... Something is seriously wrong with this cap, and I can't put my finger on it yet. going to try something now and see how it fares.


    As far as I can tell, there has to be a bug somewhere in this cap. It seems to be realted to your lerp call in the second to last event. I don't know enough about lerp to check your forumla, but the problem seems centred aroung that particular event.

    I've had no luck in pin-pointing the exact cause, maybe someone else will have better luck, but I would be prepared to ready this for tracker submission as a bug if nobody else can suggest a solution.


  • Have a look at this, it might help.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Use the bullet behavior not one massive sprite for hit detection.

  • Like Max said - you could create a bullet sprite the same width as your beam, facing in the same direction, and just make it, say, 200 pixels long. Then you could give it the Bullet behaviour, make it Instant Hit, and set the speed to 200.

    Instant Hit just keeps looping in the same tick until it hits something, so it'd strike the target immediately. If it traveled 10,000 pixels at the size and speed I said above, I guess that'd be, what, 50 loops? Should be no problem for the CPU.

  • You could do that, but the collision would only be accurate to the nearest 200 pixels, which is quite a large error. You might want to use a smaller object (maybe 30x30) and have a shorter maximum distance to save CPU (is your layout really going to need you hitting things 10,000 pixels away??)

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