User Tag List

Results 1 to 7 of 7

Thread: Gravity for enemies

  1. #1
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCHTML5 Export ModuleMac Export Module

    Join Date
    Jun 2012
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Gravity for enemies

    Is there a easy way to make enemies with gravity? I`m making a platform game, I made a lot of enemies some of them have gravity that I programed using colision box. The problem is. I f I have 2 of them coliding each other and I kill one of them the one who has been killed "steal" the colision box from the other.

    Is there a easy way to make an enemy with gravity without using colision box? I ve tried to use fastloop however it appears that don`t work with more tham one instance of the same object. =(

  2. #2
    Clicker Fusion 2.5Android Export ModuleSWF Export Module
    Ziplock's Avatar
    Join Date
    Oct 2013
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, if you have behaviors for an object and multiple instances of that object, movement can get wonky because mmf doesn't know which instance it's supposed to apply behaviors to, so it usually goes for the most recently created one (or something like that). You need the ForEach object extension:

    ForEachSetup2.exe

    Run your loops through this and everything should work.


    Put an instance of the ForEach anywhere in the field and use something like the following code:

    Always:
    -->ForEach Instance... Start ForEach Loop for Object... "Enemy Movement"... Select Object... Enemy

    ForEach Instance... On ForEach Loop for Object... "Enemy Movement"... Select Object... Enemy
    -->Enemy... Set Flag 1 on
    -->Fast Loops... Start Loop... "Enemy Gravity"... Gravity Times
    -->Enemy... Set Flag 1 off

    On Loop... "Enemy Gravity"
    +Enemy... Flag 1 is on
    -->Gravity Movement


    I know this code is incomplete, but I don't know exactly how you want your gravity to work, so... just play around?

    Good luck.

  3. #3
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCHTML5 Export ModuleMac Export Module

    Join Date
    Jun 2012
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey, thanks man! =D
    Do you know if this have a big performance impact?

  4. #4
    Clicker Fusion 2.5Android Export ModuleSWF Export Module
    Ziplock's Avatar
    Join Date
    Oct 2013
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well like always when optimizing, try to make sure to stop your loops when you don't need them. The "Always" condition should be changed to something a little more specific to your project. Also, like anything else, limit your transparencies and total number of objects, optimize your sounds, organize your code, and track your frame rate in standard display to make sure. But I've gone all over, including this board, many times to try to fix optimization problems (that's actually when happygreenfrog gave me this extension). Don't plan for performance lag, just do the best you can to prevent it and deal with it when it comes.

    But that small little code snippet shouldn't cause problems, rather it should fix them because you don't need to create individual, identical objects with lines and lines of code for each.

  5. #5
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCHTML5 Export ModuleMac Export Module

    Join Date
    Jun 2012
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks man! Unfortunatly It is still having problems with the instance.
    I made a small test with no gravity however with terrain correction for irregular terrain

    Is in play area = > start for each loops for enemy 1

    ok
    them

    ON LOOP (ENEMY1UP) -> set enemy 1 y-1
    ON LOOP (ENEMY1DOWN) -> set enemy 1 y+1

    FOR EACH OBJECT ENEMY1
    COLISION OVERLAPING BACKGROUND -----> START LOOP ENEMY1UP 10TIMES

    FOR EACH OBJECT ENEMY1
    (NEGATE) COLISION OVERLAPING BACKGROUNS) --------> START LOOP ENEMY1DOWN 10 TIMES

    It worked with 1 enemy, when I put 2 in the screen if one of them start to go up the other one go up too. So the fastloop act with the 2 stances. =(

    Sorry for my bad english

  6. #6
    Clicker Fusion 2.5Android Export ModuleSWF Export Module
    Ziplock's Avatar
    Join Date
    Oct 2013
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don't have to waste time with apologies for bad english. I think it's fine.

    You're forgetting the flags during your foreach loop. This will make each of them run independently.

    It should be something like this:

    Is in play area:
    -->Start ForEach loop "Enemy Move" for Enemy

    On ForEach loop "Enemy Move" for Enemy
    +Enemy is overlapping a backdrop:
    -->Set Enemy Flag 1 On
    -->Start Loop "EnemyUp" 10 Times
    -->Set Enemy Flag 1 Off

    On Loop "EnemyUp"
    +Enemy Flag 1 is on:
    -->Set Enemy y to Enemy y-1

  7. #7
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCHTML5 Export ModuleMac Export Module

    Join Date
    Jun 2012
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Woah, it is working now! =D
    Hey, thanks man I didn`t knew that I had to use flags

    Thanks again! =)

Similar Threads

  1. Gravity and PMO?
    By darkmanx_429 in forum Fusion 2.5
    Replies: 3
    Last Post: 22nd March 2014, 12:47 AM
  2. Problem in the gravity for enemies
    By Ls2 in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 3rd August 2011, 03:50 AM
  3. thrown enemies not detecting other enemies
    By mobichan in forum File Archive
    Replies: 4
    Last Post: 8th April 2009, 06:40 PM
  4. Enemies with gravity
    By Hempuli in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 30th July 2008, 01:10 AM
  5. Simpliest way to give all enemies Gravity/Physics?
    By Zenoff64 in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 3rd May 2008, 02:31 AM

Posting Permissions

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