User Tag List

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

Thread: Trying to get multiple enemies to jump independently.

  1. #1
    Clicker Fusion 2.5
    Fusion 2.5 (Steam)Fusion 2.5+ DLC (Steam)

    Join Date
    Apr 2012
    Posts
    377
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Trying to get multiple enemies to jump independently.

    Hello! I'm currently programming a bunch of jumping slimes, and I've run into a snag that I've experienced before, but I can't remember how to solve it!

    As it is, if one slime is touching the ground while anotheri s jumping, it will mess up the jump, due to a conflict in a fastloop that says "If slime is touching ground, subtract from the y position" to avoid falling below the ground.

    The code is as follows.

    Height of Slime < 8
    set height of Slime to Height("Slime")+0.45

    Height of Slime <> 0
    start loop "slime" Abs(Height("Slime") times

    On loop "slime"
    Height of Slime > 0
    set Y of Slime to Y("Slime")+1

    On loop "slime"
    Height of Slime < 0
    set Y of Slime to Y("Slime")-1

    On loop "slime"
    Slime is overlapping a backdrop
    Height of Slime <0
    set Y of slime to Y("Slime")+1
    set height to 0

    On loop "slime"
    Slime is overlapping a backdrop
    Height of Slime >0
    set Y of slime to Y("Slime")-1
    set height to 0

    Now an individual slime will behave exactly like I want it to, but if there is more than one they will mess up.
    I tried solving this by a spread value and then referring to it in the loop, but the problem there is that since the gravity is dependant on the "slime" loop starting Abs(Height), I can't refer to the loopindex properly as one would do with

    On loop "slime"
    Id of Slime == Loopindex
    Slime is overlapping a backdrop
    Height of Slime <0
    set Y of slime to Y("Slime")+1
    set height to 0

    Any ideas on how to do this? If I can I'd like to keep the gravity system, as the jumps become precisely as smooth as I want them.

    Any help is appreciated, thank you.

  2. #2
    Clicker Multimedia Fusion 2 DeveloperiOS 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)
    King_Cool's Avatar
    Join Date
    Aug 2008
    Posts
    2,335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just a suggestion from reading the topic:

    I thnk it would be very wize to create Virtual Controll Buttons for the Enemy Object.
    For example,
    Flag1 = Right
    Flag2 = Left
    Flag3 = Jump

    This way each Enemy knows when he/ she is performing an action without getting confused

  3. #3
    Clicker Fusion 2.5
    Fusion 2.5 (Steam)Fusion 2.5+ DLC (Steam)

    Join Date
    Apr 2012
    Posts
    377
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hiya! The problem with having action-states like that is that the gravity part keeping the slime from falling through the earth needs to be active at all times, but only affecting one slime at a time. If I add a pre-requisite that a slime has to be in the jump state to be affected, they will all fall down from the very beginning. Thanks for the idea though!

    My current train of thought is to have a loop in a loop.
    I'll loop through Nobject("Slime") times, and in every loop i will perform the gravity checks, and if the id of the slime corresponds to the loopindex of the main loop, the gravity of that slime will be checked. I haven't tried this yet, but does it seem like a valid idea?

  4. #4
    Clicker Fusion 2.5iOS 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)
    SolarB's Avatar
    Join Date
    Feb 2012
    Location
    Melbourne
    Posts
    904
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Nifflas has some jumping things in Knytt stories, there's an .mfa of that floating around somewhere. Could be useful.

  5. #5
    Clicker Fusion 2.5
    Fusion 2.5 (Steam)Fusion 2.5+ DLC (Steam)

    Join Date
    Apr 2012
    Posts
    377
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found an mfa, but I couldn't find any enemy a.i programming in it, however.
    I guess my main problem is how to have a loop that defines fallspeed by iterating in relation to the gravity value, while still selecting slimes based on loopindex. To do this I'd need to do a loop within a loop, afaik, but is that even possible?

  6. #6
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Loops within loops are possible and used almost all the time. In this case, ForEach would be a little useless (it doesn't have a way to run a loop for the currently selected obejcts so you have to use MMF2's slower fastloops instead). You can loop over each object and then on each of those loops run a subloop. You can get the index of both the outer loop and the inner loop because the loop index expressions let you specify the loop name.
    Working as fast as I can on Fusion 3

  7. #7
    Clicker Fusion 2.5
    Fusion 2.5 (Steam)Fusion 2.5+ DLC (Steam)

    Join Date
    Apr 2012
    Posts
    377
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How would it be formatted if i wanted to run a subloop?
    In pseudocode:
    On Loop "Mainloop" for Slime:
    run Gravityloop for Abs(Gravity("Slime")) times
    and then in the gravityloop

    If ID of Slime equals Loopindex
    Slime is overlapping a backdrop
    set slime y to slimey-1 ?
    Sorry if it all comes out a bit jumbled.

  8. #8
    Clicker Multimedia Fusion 2 DeveloperiOS 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)
    King_Cool's Avatar
    Join Date
    Aug 2008
    Posts
    2,335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I made this using ForEach Object ( ForEach loops ).
    Hope it helps.

    Objects with "Enemy" Qualifyer are considered Enemies and act like Enemies.
    Objects with "Obstacle" Qualifyer are considered solid Obstacles, which "Enemies" interact with.

    For this example to work:
    - All collision masks have to be square
    Attached files Attached files

  9. #9
    Clicker Fusion 2.5
    Fusion 2.5 (Steam)Fusion 2.5+ DLC (Steam)

    Join Date
    Apr 2012
    Posts
    377
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That seems really awesome King_Cool, although that particular code demands every obstacle to be an active object, no? Still, I'm going to mess around with it and see what I can do!

  10. #10
    Clicker Fusion 2.5
    Fusion 2.5 (Steam)Fusion 2.5+ DLC (Steam)

    Join Date
    Apr 2012
    Posts
    377
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Test slime.mfa


    This is a small example of the slimes being used. The masks are currently set to visible.
    As it is, the jumping works some of the time, but sometimes the slimes get stuck to the floor, and I can't seem to locate the exact circumstance.
    Any ideas what might cause it?

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Enemies in Side-Scroller Can't Jump
    By Fralex in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 3rd June 2012, 10:20 PM
  2. Enemies can't jump sometimes
    By Fralex in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 11th July 2011, 12:34 AM
  3. Multiple enemies
    By Blackwolfdave in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 14th February 2011, 01:55 PM
  4. Please help with multiple enemies
    By ionside in forum Multimedia Fusion 2 - Technical Support
    Replies: 15
    Last Post: 19th November 2008, 06:01 AM
  5. Multiple platform enemies using PMO
    By fodo in forum File Archive
    Replies: 3
    Last Post: 25th June 2008, 12:02 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
  •