"Ninja Rope" pendulum swinging with Platformer behavior

swing

I am working on a platformer with “ninja rope”/grappling hook mechanic, but I think I am attempting something that can’t be done with the current platformer behavior, but I am hoping to be proven wrong.

I am using platformer behavior for the “on the ground” gameplay and “Put an object around position” with some math for the rope swing. However, because the platformer and Movement/Position from “Common Actions for all Objects” do not interface with one another, if I have the player swinging they do not trigger collisions. The collisions condition seems to work, but separate the objects does not (the character jitters when hitting a platform OR goes through it). Also, the velocity does not carry when switching between swinging and ground.

I was wondering what are my options? I don’t really want to use physics if I don’t have to and recreating a platformer either as events or js code blocks is not really something I want to do (in that case I would use a different engine in that case, where I can just write code).

If the physics is the only way to go, is there an example of a simple platformer done with physics?

If someone wants to see the code it is here. It is a mess, I am was experimenting trying to solve the issue.

Edit: I jerry rigged the collisions - it is not pretty, but it works (with a small side effect, but I can live with it if not better solution is found). It seems I was trying to move player towards the end of the rope, and the rope was not checking for collisions. It is still a hacky collision solution, but at least it is something.

Now all I need is to find a good way to transfer the force from swinging when the rope is released, into movement for the player that will work when the platformer behavior’s gravity is working once again. Any ideas?

2 Likes

Very simple idea: Don’t use the platformer behavior. It’s sure good for some basic platformer stuff, but It doesn’t have physics which is something people would expect a platformer to have. Consider using the physics2.0 for the character if you want to do anything developped with it. For the rope I would create multiple instance of a very small one and joint them, and joint one to the player and to the target, if they are none it just falls, let gravity do it’s job.

2 Likes

Yeah, I was playing around the Physics2.0 examples just now and the performance is surprisingly good and it seems not too hard to work with. I might try to make a simple platformer with it over the weekend, see how it works (unless someone already made one and I can peek :wink: )

I never worked with Physics before (mostly did tiny pixel games),and I remembered playing Gish back in the day, which was pretty sluggish and the idea of physics platformer = sluggish got stuck in my mind.

The rope I am going for will be just a straight line - so a single Revolute joint between two objects would probably be all I need. So it should be pretty easy.

Are there any big limits or other no-nos when working with Physics2.0? I read on a wiki that static objects can only get upto 50 meters. Does that mean that on a long level I would need more than one object to make a solid, static floor?

1 Like

One thing I can warn you off is that I noticed that crashes are much more likely to happen on misstypes. I often saw people reporting a bug because their game crashed because execution stopped after giving invalid arguments into it. Personally I’ve never had problems with physics but I only used them once in a very basic problem solving challenge that I made for a friend (had to test it first). I have not much creativity, I never had any good ideas, so I stick to raw developing on GDevelop (Extensions) and to helping on the forum :wink:

2 Likes

Thanks Diana,
Just FYI - this code is a mess, it is a decent starting point on seeing how someone could make a pendulum swing, but it is not complete by any means. Use at your own peril :stuck_out_tongue:

@arthuro555 - Thanks for the heads up. I guess physics simulation has less tolerance for getting a wrong or NIL var. Will definitely keep this in mind. :slight_smile:

EDIT: My first tries to get a good physics platformer are not great. There is a bunch of edge cases that I need to recreate with events. Another problem is that I want my platforming to feel a bit more precise and “twitch” and the physics seem to make it more floaty or heavy feeling.

Will keep poking on it, see If I can get it to a point where I am relatively happy with the feel of the platforming, but I am not giving up on my other approach (platformer behavior + some math) just yet :stuck_out_tongue:

3 Likes

Can you give me a reference what you are trying to achieve. An animation or game reference would be nice

1 Like

The biggest point of reference is ninja rope mechanic from the Worms series (here’s a youtube example). I am shooting for a simplified version, without the rope “warping” around objects. Here’s an example of what I am trying to recreate from a PICO-8 project:

runny2_2

Notice the horizontal “force” transfers when releasing the rope (there is also a jump, but that can be done easily) and the collisions work the same way as during on the ground.

The problem I run into in GDevelop is that PlatformerObject uses its own collision system and does not take into account direct changes to X,Y (via any events/actions that change position not “add force”). You can’t access the current speed or deltaX/Y of the platform object to manually translate the new X,Y from swinging into what PlatformerObject’s collisions can handle.

EDIT: I am also having issues translating “future X,Y” into a force (from common actions). Distance *60 (the amount of pixels I want to move in the next frame * 60 frames) should give me the required force of how many pixels per second, but when called with using “Add a force toward a position” with position of future X, future Y does not seem to cut it. I think it might have something to do with platformobject behavior “kicking in”?

Hope that makes sense.

3 Likes

I am trying to make a game with a similar swing mechanic. Can you send a copy of the gdevelop game file? It would be appreciated.

Have you tried a tween when the release is done? Could It be configured into taking the speed of the swing as a base for the X distance to move? Using a variable holding the last direction you have input (left, right) you could add a tween toward that direction, simulating the swing force.

Of course, it means to add another behavior to the character.

1 Like

Ok, Let me see if it works.

Hey man I believe that to make extensions you have to be even more creative, because you have to kind of imagine what’s doing jaja not just create an extension plus you’re solving issues and most valuable you’re saving time to people.
thanks for your extensions