User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13

Thread: Perfect collision detection for bullets

  1. #1
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module

    Join Date
    Mar 2013
    Posts
    264
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Perfect collision detection for bullets

    I've managed to avoid using Fastloops during my use of Clickteams products, until now.

    Im creating a 2D sidescrolling shooter where you can shoot in 8 directions and the bullets that you shoot often travels fast.
    Currently im using "Launch object" when im shooting, and the trajectory is traveling at a speed of 100 or even more which makes the collision detection with obstacles pretty bad (and sometimes even totally misses the target = going straight through).

    I've been reading a bit about Fastloops before to fix these problems, but I've never really had use of em and now it seems that I REALLY need them in order for my trajectory collision to work flawlessly.

    Is there any good example files that I can use for my problem? Been looking at different Fastloops-examples, but havent really found anything that resembles my situation.
    What I need to know is how to shoot something in 8 directions using fastloops, where I also can alter the speed of the bullet and with perfect collisiondetection ofc.

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Simflare's Avatar
    Join Date
    Oct 2013
    Location
    Australia
    Posts
    374
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Fastloop Assist

    Using fastloops is quite simple once you know how. There's a great free guide on the official Clickteam website under the "Support > Tutorials" tab. Go to the "Intermediate" tutorials and scroll down to near the bottom. Fastloops are essential if you want pixel perfect collision detection. This is because it will check every single frame for a collision, rather than the default which is to move the object, then check for a collision, which is why your bullets sometimes miss. You need to keep in mind though that fastloops can cause a lot of slowdown for mobile games. Are you making a mobile game? If you are, then you need to learn how to optimize them. If you're only making games for PC then it probably doesn't matter.


    Optimizing Fastloops

    It's the 'On Loop' command that causes slowdown. You can reduce slowdown by having all "On Loop" conditions inside an inactive group, and only activate the groups when the fastloops run, then deactivate it when it's not in use again. From what I understand, when an 'On Loop' condition is read, Fusion will check all of the other 'On Loop' conditions and events in your game before running the loop or doing anything else. And it does this for every single 'On Loop' command. But by putting them inside inactive groups, Fusion won't read them until they're needed. Fusion won't read anything inside an inactive group. And remember that all code is read top to bottom 60 times per second if you're running at 60fps.


    If you want to learn more about optimization, you can check out my blog post, which also has some other great links, like this one.

    For most things though, PC's these days are so powerful you can get away with a lot without optimizing for pure PC games. However, if you were intending it to be a Flash game played over the web, you may need to optimize. Mobile games you have no choice but to optimize.

    Hope that helps

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module

    Join Date
    Mar 2013
    Posts
    264
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the response Simflare.
    I'll check it out and come back here if there's anything else.

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Simflare's Avatar
    Join Date
    Oct 2013
    Location
    Australia
    Posts
    374
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No worries.

  5. #5
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleiOS Export ModuleSWF Export Module
    Skyhunter's Avatar
    Join Date
    Jan 2007
    Location
    Croatia
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You dont actually need a fastloop for perfect collisions as long as the bullet is as wide as the speed its travelling. so if its travelling 6 pixels a frame, it needs to be 6 pixels wide.
    Which you can achieve even if the bullet is not graphically that wide:

    by giving it some blank space and uncheck fine detection.
    OR
    with fine detection put some alpha behind it.

  6. #6
    Clickteam Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Simon's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    2,735
    Mentioned
    65 Post(s)
    Tagged
    3 Thread(s)
    Just a note about the fast loops in disabled groups...

    Since Fusion 2.5 that is no longer really a concern, as the efficiency of fast loops has been greatly improved, partly by pre-indexing the location of "on loop" conditions within the events.

    The comment about the wide bullet is a good one, although unless I am getting muddled (it does happen!) wouldn't you want a bullet image which is long rather than wide, ie. with the blank space in front of and below the bullet so it has extra dimension in the direction of travel only?

    Another thing you can try is the move safely object, which is designed to get around this exact problem.

  7. #7
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleiOS Export ModuleSWF Export Module
    Skyhunter's Avatar
    Join Date
    Jan 2007
    Location
    Croatia
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah i did meant longer, in the direction of travel

    Not that good at english sometimes.

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Simflare's Avatar
    Join Date
    Oct 2013
    Location
    Australia
    Posts
    374
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    move safely object? Never heard of it. Got an example of how to use it?

    As for making an object the same length as the speed, that's a good idea. I wouldn't recommend using alpha channels for a mobile game, as they drain memory, apparently. But you could use a block of colour behind your bullet and filter it out with Fusions in built transparent colour.

    Yeah I heard the loops are supposed to be more efficient, but I also heard there were cases where that was not the case.

  9. #9
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    Francois's Avatar
    Join Date
    Jul 2006
    Location
    Montpellier, France
    Posts
    6,920
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    If ALL the "On loop" condition of your fast-loops use a single string as a parameter, I mean all of them, then the fast loops will be a lot faster.
    But if you use one or more) calculations in the parameter of one of the "on loop" event, the system reverts to the old algorythm, which is slower.

    Bullets : internally, I do cut the movement in small chunks to avoid this kind of problems. It does work (if I did not this would occur a lot more and many games would have the problem), but I had to decide not to cut it too small, as this would have slowed down everything. So it you have a smalll fast bullet, gowing toward a small fast object that is going toward the bullet, this may happen. The simplest solution for me, is to have a hidden collision detector behind the bullet (set its position with Set X and Set Y coordinate) and detect the collisions with the detector.
    If you have more than one bullet at the same time, you'll have to use the For each actions of Fusion 2.5. Here is how.

    - In your frame, prepare many detector objects ready to be used, oout of the frame. Just a static movement
    - Shoot your bullet(s)
    - ALWAYS
    *** (Bullet) For each one of two objects (Detector), loop name "detection"
    - On each object "Bullet", loop name "detection"
    + On each object "Detector", loop name "detection"
    *** Set position of "Detector" to Position of Bullet

    For each on two objects is really powerful : it associates two kind of objects on a one-to-one basis. Note that on the line called by the loop, you must have TWO "on each" object conditions, one for each one of the objects of the loop.

  10. #10
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module

    Join Date
    Mar 2013
    Posts
    264
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    gonna bump this thread again.

    i've checked a bunch of fastloop examples on how to apply pixel-perfect collision to my bullets in my shooter-game, but it still leaves me clueless. im having a hard time to grasp fastloops and how they work.
    in my game, i have several different weapons with bullets flying in straight lines, multiple lines at the same time (spreads out) in all sorts of directions.

    isnt there a simple way to apply fastloops to every single bullet without coding it into like 25 lines of code?

    ive also tried using the "Move Safely Object" in order to make the collisions pixel-perfect without any luck.

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Perfect 360 degree shooting AND perfect hit detection?
    By D_Light in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 9th May 2013, 04:30 AM
  2. Possible bug in PMO collision detection
    By K1kk0z90 in forum Multimedia Fusion 2 - Technical Support
    Replies: 9
    Last Post: 4th August 2011, 01:56 PM
  3. détection collision
    By graboide in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 12th December 2010, 05:24 AM
  4. Bug with overlapping collision detection?
    By mobichan in forum SWF/Flash Export Module Version 2.0
    Replies: 5
    Last Post: 2nd April 2010, 11:16 PM
  5. Collision detection
    By Crash86 in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 1st April 2007, 04:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •