Invert Gravity Platformer (cross-post)

Discussion and feedback on Construct 2

Post » Sun Sep 04, 2011 6:35 pm

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:
[code]acts.SetGravity = function (grav) {
     this.g = grav;
     if (this.g < 0)
          this.g = 0;
};[/code]
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.
B
14
S
1
G
2
Posts: 85
Reputation: 2,810

Post » Sun Sep 04, 2011 8:49 pm

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.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Sun Sep 04, 2011 9:23 pm

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.
Image Image
Scirra Founder
B
125
S
37
G
25
Posts: 3,945
Reputation: 44,922

Post » Sun Sep 04, 2011 9:38 pm

Also, checking out.
Your negative gravity might be canceled by the maxfall speed property

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

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.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Sun Sep 04, 2011 9:50 pm

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.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Mon Sep 05, 2011 3:19 am

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.)
B
14
S
1
G
2
Posts: 85
Reputation: 2,810


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 13 guests