User Tag List

Results 1 to 4 of 4

Thread: Simpliest way to give all enemies Gravity/Physics?

  1. #1
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module

    Join Date
    Aug 2006
    Posts
    234
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simpliest way to give all enemies Gravity/Physics?

    I can knock out AI with no problem, but when it comes to enemies and gravity, I can't figure out how to do it in mass.

    Any help would be appreciated to point me in the general right direction.

    Thanks!
    -Nick

  2. #2
    No Products Registered

    Join Date
    Aug 2006
    Posts
    984
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Simpliest way to give all enemies Gravity/Physics?

    you might want to look into the Move Safely 2 object; it won't do gravity (which is relatively easy for multiple objects), but it'll handle the collision/pushout routines for those objects (which is somewhat complex)

  3. #3
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export ModuleUnicode Add-on

    Join Date
    Jun 2006
    Location
    Australia
    Posts
    988
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Simpliest way to give all enemies Gravity/Physics?

    Have one detector for all of the objects. (A floor detector, eg a 32x2 pixel rectangle placed just below the object's feet.)

    At the start of the frame, and when the number of enemies changes, spread a value through all of the enemies.

    Always run a loop.

    On loop (you can possibly use an always for this)
    + Alt Val A of enemy is equal to loop index.
    Then
    Enemy y = Enemy y + 1

    On loop
    + Alt Val A of enemy is equal to loop index.
    Then:
    Set detector x/y to object's feet.

    On loop
    + Alt Val A of enemy is equal to loop index.
    + Detector is overlapping the backdrop/ground
    Then:
    Set Alt Value B (or a flag) of enemy to 1.

    On loop
    + Alt Val A of enemy is equal to loop index.
    + Alt Val B of enemy is equal to 1
    Then:
    Enemy y = Enemy y - 1


    Basically what is happening is, you have one detector that fits on all your enemies. Then on each loop it sets its position to the current enemy, whos ID/alt value matches the loop index. If it is overlapping a background while it is in this position then we flick a flag for that active, and on the next event it moves that object back up 1 pixel.

    I have used this many times in many engines without problems. You can expand on it and make it really complex with edge detection amongst other things, all while using just one detector object. It has never caused slow down either.

  4. #4
    No Products Registered

    Join Date
    Jul 2006
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Simpliest way to give all enemies Gravity/Physics?

    It doesn't even need to be that complicated unless you plan to have a high terminal velocity coupled with thin platforms and short enemies. All you really need to do is store two values in each object: one for how fast it's falling and one for it's y position. Each frame, you increase the falling speed by a certain amount (according to how strong you want gravity to be, and only so long as it's below your desired terminal velocity), add the current falling speed to the Y position variable, then set the object's Y position to the Y position variable. (You add because MMF is Y-down, not Y-up, and the reason you use a separate Y variable instead of changing the object's Y directly is because it makes the movement work a lot better because it can store decimals.) Then, if the object is colliding with the background, reset the falling speed to 0. MMF will automatically bounce the object back up to the top of the surface. Add a collision mask test using the object's bottom edge and you're even set for odd things like flying sideways into obstacles, all without using any sub-objects.

    If you reserve the same two alterable values in each object, you can apply gravity to any object you want simply by assigning these events to a qualifier rather than a particular object.

Similar Threads

  1. Fusion 2.5: Give Enemies Physics SpaceShip Movement
    By Top_of_the_Temple in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 15th December 2013, 10:42 AM
  2. How would one code ladder physics with reverse gravity features?
    By N64Mario in forum Multimedia Fusion 2 - Technical Support
    Replies: 15
    Last Post: 26th March 2012, 06:16 AM
  3. 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
  4. Enemies with gravity
    By Hempuli in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 30th July 2008, 01:10 AM
  5. Spacey/Gravity Physics, Inertia, etc
    By BREK in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 17th February 2007, 02:48 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
  •