User Tag List

Results 1 to 5 of 5

Thread: Objects are apparently destroyed at the end of frame, not when you command them to be

  1. #1
    Clicker Fusion 2.5

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

    Objects are apparently destroyed at the end of frame, not when you command them to be

    This is usually important, and might have caused some bugs for in the past, so I'm letting people know. After all these years, I noticed this was the case when an object that had already been set to destroy was spawning new objects in something that happened later in the frame. The documentation doesn't mention this, but I think it'd be worth including.

  2. #2
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,537
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    yes, using the "destroy" command for an active object won't run garbage collection and won't remove that object from the list of object instances, it will simply flag it to be destroyed the next time garbage collection is run at the end of each frame. So if you have any code that should never execute on objects previously destroyed in the same frame, you need to exclude them somehow, and theres no hardcoded "Is object not destroyed" condition. So for myself, I used an active object flag to indicate objects that are already destroyed, so any critical code in my engine ignores objects with flag 29 set on.

    This isn't something clickteam could easily fix since running GC is extra computation, but what they could do is remove the object from the list of instances without freeing up its memory, but make sure to free up its memory when GC is run

  3. #3
    Clicker Fusion 2.5Fusion 2.5+ DLC
    casleziro's Avatar
    Join Date
    Mar 2013
    Location
    United States
    Posts
    644
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    "This isn't something clickteam could easily fix since running GC is extra computation, but what they could do is remove the object from the list of instances without freeing up its memory, but make sure to free up its memory when GC is run"

    Sounds like a good idea. I would submit it to the bugbox.

  4. #4
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,537
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You have to be careful with changes like that because they can break backwards compatibility with projects that were coded around it. You can add a checkbox to the properties to revert to the old behaviors but then you've got more legacy code bloat, but it all takes time to debug, so is it really worth it? For most people making quick apps in MMF2, you'd never notice if destroyed objects are being considered for events. For a lot of stuff like multiple "Player is overlapping enemy" checks or whatever, a very simple solution is just to move them to (-1000,-1000) when you 'destroy' them and set all their alterable values to -1 or whatever makes sense for your code. But coupled with the object class collision mask only being redrawn at the end of frame it can lead to some odd behaviours people report here about "Is X overlapping Y" when an objects already been destroyed and moved and so on.

  5. #5
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,282
    Mentioned
    26 Post(s)
    Tagged
    0 Thread(s)
    Unless of course you run code on the destroyed object later in the game loop, then you wouldn't want it to be inaccessible before the loop ends. I agree this is a quirk, but sadly I think many of us have coded with the quirk in mind, so we would have some reworking of old code to handle this suggested change. I currently use Pixelthief's method of turning a flag on when an enemy is "inaccessible to code". You also should consider not using the "Disappearing" animation as the active object will also continue to check collisions and such while it is playing.

    Edit: Pixelthief beat me to it. :P

Similar Threads

  1. Replies: 6
    Last Post: 16th March 2016, 10:01 PM
  2. Frame remembers destroyed objects
    By Sparckman in forum Guides, Tutorials, Examples, Widgets
    Replies: 0
    Last Post: 3rd August 2014, 08:13 PM
  3. Objects destroyed next frame Problem
    By HyperspazzMan in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 3rd July 2010, 05:19 AM
  4. Object destroyed if not on frame
    By pikzilla in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 12th April 2010, 04:26 AM
  5. How far off the frame before destroyed?
    By Gibbon in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 11th April 2008, 06:05 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
  •