Ninja rope?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
gramps
Posts: 300
Joined: Thu Oct 18, 2018 2:16 pm

Ninja rope?

Post by gramps »

Apologies if this has been discussed before. A quick search didn't turn anything up.

I want to create a grappling hook or "ninja rope" type device. Has this been done before in zdoom?

I imagine this could work like this:

1. Fire the weapon; wherever it hits, the bullet puff remains.
2. When the player is farther than the rope length from the puff, adjust player's velocity.*
3. When the player hits another key, the grappling hook detaches. Maybe pressing jump reels the rope in, and releasing jump detaches the hook.

* Originally I wrote "transfer all downward velocity into sideways velocity, towards the puff," but this doesn't seem right. The new velocity should maybe directed along a line tangent to a sphere with a radius of rope length, centered around the puff. Not sure exactly how the math would look, would appreciate any pointers.

Questions:

- Will the physics as described above feel anything like a ninja rope?
- How to draw the rope in a convincing way?
- How to handle air control / swinging yourself on rope?

Alternate idea:

Thinking more about drawing the rope, it seems like it would need to be a sort of chain of actors.

If that needs to happen anyway, maybe those actors can provide the physics themselves, by fixing one end to the puff, one end to the player, and the rest of the links in the chain to the two adjacent links. The actors will be affected by gravity, and a script will run constantly, enforcing distance between each link and its neighbors.

This could add a lot of realism, like bending the rope around corners, without any complicated math. I wonder how many links in a chain like this the engine could reasonably handle?

Not exactly sure how to enforce closeness. I'm thinking just walk through each chain link, and if it's too far from the next link, propel those two links towards each other by some constant amount (more elastic rope at lower values). And maybe let the chain links push each other around?

Anyway, just brainstorming I guess. If anyone has any ideas, let me know :)
User avatar
ramon.dexter
Posts: 1520
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: Ninja rope?

Post by ramon.dexter »

Take a look at this: viewtopic.php?f=37&t=46998
gramps
Posts: 300
Joined: Thu Oct 18, 2018 2:16 pm

Re: Ninja rope?

Post by gramps »

Thanks, looks promising, will check that out!

From looking at the video in the WIP thread, I think what I want little different, though. I'm looking for a rope/chain you can swing back and forth on, more than something that just yanks you towards the hook. But this might be a good starting point.
gramps
Posts: 300
Joined: Thu Oct 18, 2018 2:16 pm

Re: Ninja rope?

Post by gramps »

I've been working on converting that thing to zscript, seems much nicer so far. Will try messing with chain physics next.

Here's what I've got so far if anyone's interested. This version uses bullet puff actor from doom as the chain body. References to the strife sounds are still in there, need to find appropriate doom sounds to replace them with.
Attachments
hookshot.7z
doom hookshot in zscript
(1.18 KiB) Downloaded 30 times
Post Reply

Return to “Scripting”