How do I Reset double jump?

Get help using Construct 2

Post » Mon Dec 19, 2016 4:11 pm

I know i can do it manually using a variable, but thats atleast 5 extra lines.
I like my programs to be as simple as possible, so im wondering if theres a way to say "reset the double jump""?
I want my players to be able to be jumping up a wall, and when they hop of to have their double jumps reset, does anybody know if this is possible?
Thanks in advance
-Blank.
B
6
S
1
Posts: 49
Reputation: 529

Post » Mon Dec 19, 2016 4:53 pm

It's too bad the platform behavior did not include an action to do that. I've checked out the runtime file for the behavior and it's a simple boolean that say if a particular instance has double jumped or not.

You could use the Browser object to inject some javascript that would allow you to manually change that variable of your player instance. Here's the code :
Code: Select all
var behavior_insts = this.runtime.objectsByUid['" & Player.UID & "'].behavior_insts
for(var i = 0; i < behavior_insts.length;i++){
    var inst = behavior_insts[i];
    if(inst instanceof cr.behaviors.Platform.prototype.Instance){
        inst.doubleJumped = false;
        break;
    }
}

This won't work once minified though.
B
69
S
28
G
24
Posts: 977
Reputation: 18,739

Post » Mon Dec 19, 2016 5:14 pm

Magistross wrote:This won't work once minified though.

Okay well thats definitely interesting, i might do it on the final build but until then i can do without, thanks alot :)
B
6
S
1
Posts: 49
Reputation: 529

Post » Mon Dec 19, 2016 6:00 pm

Maybe if @ashley notices, he'll find the time to add this to his ever-growing to-do list. ;)
B
69
S
28
G
24
Posts: 977
Reputation: 18,739

Post » Mon Dec 19, 2016 6:52 pm

Magistross wrote:Maybe if @ashley notices, he'll find the time to add this to his ever-growing to-do list. ;)

I hope he does, it doesn't seem to be requested alot thou, but it seems like you would find it under the platformer movement section lel
B
6
S
1
Posts: 49
Reputation: 529

Post » Mon Dec 19, 2016 8:06 pm

Yes, it's a simple addition to the Platform behavior. An action to set the "doubleJumped" boolean manually. Modifying an official behavior is pointless, and creating a new one with additional functionalities isn't much better. Your best bet is hoping for Ashley to take notice of this thread and apply the modification "officially".

Meanwhile, you could encapsulate your "Reset double jump" routine in a function, and use this function inside your code. It will make refactoring easier when (if?) the time comes.
B
69
S
28
G
24
Posts: 977
Reputation: 18,739

Post » Tue Dec 20, 2016 12:26 pm

Is this really necessary? You can effectively force another jump just by setting the vector Y to a negative value, so you can keep hopping away as much as you like...
Scirra Founder
B
395
S
232
G
88
Posts: 24,371
Reputation: 193,762

Post » Tue Dec 20, 2016 3:06 pm

Ashley wrote:Is this really necessary? You can effectively force another jump just by setting the vector Y to a negative value, so you can keep hopping away as much as you like...
But then that's another "jump" logic that you have to create.

Makes me wonder, perhaps a "force jump (even when not on platform)" action would be more versatile ?
B
69
S
28
G
24
Posts: 977
Reputation: 18,739

Post » Tue Dec 20, 2016 5:37 pm

Magistross wrote:Makes me wonder, perhaps a "force jump (even when not on platform)" action would be more versatile ?

That's exactly what the set vector Y action does. A jump is the same as "if on ground, set vector Y to negative jump strength".
Scirra Founder
B
395
S
232
G
88
Posts: 24,371
Reputation: 193,762


Return to How do I....?

Who is online

Users browsing this forum: evillair, vankizzle, Yahoo [Bot] and 8 guests