Invert Gravity Platformer (cross-post)

0 favourites
  • 6 posts
From the Asset Store
10 Retro songs ideal for platformers or farming games
  • This was originally posted here but I was recommended to put this here, as it will get more exposure. It turns out (and I confirmed it), that the Platform plugin works exactly as I want it in Construct Classic, but on Construct2 it's limited.

    What I essentially want is a platformer plugin, which can invert its own gravity and go on the roof. Sounds simple enough.

    I edited the platformer plugin, and there was the snippet:

    acts.SetGravity = function (grav) {
         this.g = grav;
         if (this.g < 0)
              this.g = 0;
    };

    So I simply removed the if() case, and was able to set my character's gravity to -1500 and it worked perfectly; he 'fell' onto the roof, just like I assumed he would.

    I want to have it able to be changed in the game, and I've set up keys to change the gravity (from 1500 to -1500). However, every time I go to change his gravity value in an event, it initializes it back to zero for some reason.

    Is there some type of fallback in the event code which does this?

    tl;dr the event manager, for some reason, won't let me change a behaviour plugin to negative, even though the plugin has been altered to allow for that.

  • When you say "removed the if() case", do you mean you removed only the "if (this.g<0)" line, or did you also removed "this.g = 0;" ?

    If you didn't remove the second line do it.

    Also, maybe you should post a capx and your modified version of the platformer behavior. It would be easier to check out.

  • I totally agree on removing the default to 0, I think Ash put it in as an error check when it's not needed, I'll pass it on to Ash and make sure it's removed in the next build.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Also, checking out.

    Your negative gravity might be canceled by the maxfall speed property

    // Not on floor: apply gravity
    [...]
    // Cap to max fall speed
                   if (this.dy > this.maxFall)
                        this.dy = this.maxFall;
    

    If you also put a negative maxfall speed, then by default, dy will be > to it (-2 is superior to -6 for example).

    Once again, that would be easier to check out with the capx and the modified behavior.

  • The behavior is currently written with the assumption gravity is always down. This means there might be subtle bugs in having gravity going up which might not be immediately obvious. I was going to add a 360 degree gravity option for Platform, but just haven't got round to it (the development philosophy is to get the bare minimum covered for lots of features rather than have really good features on some things and no support at all for others). Still, I can push it up the list and try have it done for the next build or two.

  • Guys: I don't want to sound ridiculous but it's suddenly started working exactly as I wanted. I don't know what has changed, and I don't think I touched anything. I don't necessarily want to touch anything anymore lest it explodes.

    Thanks for the help :D

    Argh! Why would it just suddenly work when giving me a headache for so long?

    Thanks guys. Sorry I wasted your time. I really should have just waited for Construct's self-healing properties.

    (By the way I'm a big fan of the engine and the stuff you guys have done. I bought it yesterday. Also for some trivia, I was in a unit with David 18 months ago. He's a pretty cool guy. He makes games about UFOs abducting strawberries and doesn't afraid of anything.)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)