User Tag List

Results 1 to 8 of 8

Thread: If bullet overlaps a certain object, damage the shooter of the bullet

  1. #1
    Clicker Multimedia Fusion 2

    Join Date
    Jul 2010
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    If bullet overlaps a certain object, damage the shooter of the bullet

    Hi all,

    In my game, I want to have this function, that when an enemy shoots a bullet, if that bullet overlaps with a certain object, the enemy that shot this bullet receives the damage of the bullet. I tried to achieve this in the following form (actions are marked with "--->"):

    Alterable value "shoot interval" of object "enemy1" = 0
    ---> Create object "bullet1" at action point of object "enemy1"
    ---> Set alterable value "who shot" of object "bullet1" to the fixed value of object "enemy1"

    Object "bullet1" is overlapping object "returndamage"
    + Fixed value of object "enemy1" = alterable value "who shot" of object "bullet1"
    ---> Subtract 50 from alterable value "health" of object "enemy1"
    ---> Destroy object "bullet1"

    Unfortunately, my idea did not work and nothing happens when the bullet overlaps with the "returndamage" object. Could anyone please help me with this matter?

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleMac Export ModuleUnicode Add-on
    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)
    AyreGuitar's Avatar
    Join Date
    Jan 2011
    Location
    Wales, UK
    Posts
    1,113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, it seems to work in this quick example I made, so perhaps your code isn't the same as your post or it's something else in your code? (Or I misunderstood your code!)
    Attached files Attached files

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    KLiK-iT's Avatar
    Join Date
    Sep 2011
    Location
    New Jersey
    Posts
    2,862
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    It should work. Are you using layers? If so your bullet might be in a different layer then the enemy.

  4. #4
    Clicker Multimedia Fusion 2

    Join Date
    Jul 2010
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for your reply, AyreGuitar. Your code seems to be the same like mine, but yeah, yours is working perfectly. Hmmm, I have to take a closer look at my code to see if there is anything wrong. Thanks again!

  5. #5
    Clicker Fusion 2.5 DeveloperiOS Export Module
    ChrisBurrows's Avatar
    Join Date
    May 2011
    Location
    Tasmania, Australia
    Posts
    622
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Remember, for the condition "Fixed value of object enemy1 = alterable value who shot of object bullet1", you must use Compare To One Of The Alterable Values and not Compare Two General Values.

    Explained here.

  6. #6
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Posts
    1,305
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    It won't work if you have multiple objects shooting at the same time.
    If that happens, MMF2 will create one bullet for each enemy1, but it will only set the whoshot value of the last bullet it creates (the rest will stay at their default value of "0") - which means that the other event will only work for one of the bullets.
    AyreGuitar's version only works because he staggered the shooting, so it's never possible for more than one bullet to be created per frame (it will break if you remove the first line).
    In an actual game, you will need to put your first event inside a ForEach loop in order for it to work correctly.

  7. #7
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleMac Export ModuleUnicode Add-on
    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)
    AyreGuitar's Avatar
    Join Date
    Jan 2011
    Location
    Wales, UK
    Posts
    1,113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    StardustSpeedman - Muddy Mole is correct - sorry for a misleading example (I should have realised!)

  8. #8
    Clicker Multimedia Fusion 2

    Join Date
    Jul 2010
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi All and thank you for all the replies!

    Yeah, I finally got it to work now. One of the problems that I had, was exactly the one that MuddyMole mentioned. Another problem was the order of the events. I had an event that would make the "returndamage" object invisible before the event that would return the damage, and I made this second event work only if the "returndamage" object was visible. So, all I had to do, was to change the order of the events, so that first, the return damage event would apply, and then the event that would make the "returndamage" object invisible.

    The problem that MuddyMole mentioned took me a lot more time to figure out, but I finally managed to work around it. Too bad, that I revisited this thread only after I spent so much time to solve my problem. :P

Similar Threads

  1. Bullet-Time: There is no Foo!
    By Dines in forum Articles
    Replies: 24
    Last Post: 2nd June 2013, 11:04 PM
  2. Bullet not hitting object? :/
    By Outcast in forum Multimedia Fusion 2 - Technical Support
    Replies: 9
    Last Post: 14th February 2011, 08:33 PM
  3. how to get a bullet to stop?
    By pikzilla in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 28th November 2009, 03:38 AM
  4. Looking for: Bullet & Particle Object
    By dub in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 9th October 2008, 12:11 AM
  5. bullet holes.
    By piki in forum Multimedia Fusion 2 - Technical Support
    Replies: 19
    Last Post: 8th October 2007, 04:43 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
  •