Jump to content
A 2021 backup has been restored. Forums are closed and work in progress. Join our Discord server for more updates! ×
SoaH City Message Board

[MMF2] Respawning Objects Off Screen


Recommended Posts

I haven't been able wrap this around my head but I was wondering how to be able to respawn objects when offscreen. Example: Say there's a gimmick such as a balloon Sonic would have to grab on to float to a platform too high to jump yet if the balloon pops, Sonic would have to grab the balloon again to progress. I'm looking for a way to do that without having to make more than one object with the same events. Using the newest Sonic Worlds engine BTW.

Link to comment
Share on other sites

I imagine you could do something like, at the start of the level, assign each balloon's starting X & Y positions to two Alternate Variables. When the 'popping' animation plays, don't destroy the balloon...just making it invisible and send it back to wherever it's starting point is (based on the Alternate Variables).

Then, when Sonic's far enough away from it that it's off-screen, make the balloon reappear [check this by getting the absolute value of Sonic X/Y position minus the balloon's X/Y position, I think the function is abs()].

Hope that gives you some ideas.

  • Like 1
Link to comment
Share on other sites

Ok, so to break USC's suggestion down and perhaps improve on it a little bit...

[respawnable]

alterable value A - origXPos

alterable value B - origYPos

alterable value C - state

events:

if (respawnable.state == 0) will precede all your normal movement events and whatnot.

When your destruction event occurs, respawnable.state = 1 and respawnable.makeInvisible()

Now, your other set of events for when the respawnable object is dead...

if (respawnable.state == 0)
    if (Pow((camera.xShift + [1/2 screenXRes] - respawnable.xPos)),2) > [screenXRes ^ 2])
        respawnable.state = 1
        respawnable.makeVisible()
        respawnable.xPos = respawnable.origXPos
        respawnable.yPos = respawnable.origYPos

respawnable as an object should probably be a qualifier since this sort of thing can be recycled.

Also, whenever I used brackets - [], that indicates that this is a value you should have calculated before hand since to the best of my knowledge, MMF doesn't do constants.

  • Like 1
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...