[Niagara 4.25] Rope Physics Mini Tutorial

[Niagara 4.25] Rope Physics Mini Tutorial

ezgif-5-d252621758f5
Hi guys here is a little tutorial of how you can create some rope physics using pendulum constrain.

  1. Create new Niagara emitter with empty template.

  2. Set your Emitter State loop behavior to once and duration to infinite:

1

  1. Add Spawn Burst module and set spawn count to 10

2

  1. Remove Initialize Particle from Particle Spawn section.
  2. Uncheck kill particles in Particle State node and set it to it to die when emitter deactivates.

5

  1. Remove sprite renderer and add mesh renderer to S_Arrow (from plugin content)

  1. After that add pendulum nodes to Particle Update section Pendulum setup and Pendulum Constraint (press fix issues so it will add Calculate Accurate Velocity node also).

  2. Enable Spring Driven Constraint in Pendulum Setup and update module with those parameters:

9

  1. Also Enable Calculate and Output Potential Energy in Pendulum Constraint node.

10

  1. Add Orient Mesh to Vector module and set look at direction to be Pendulum Axis:

orient

Overall emitter should look like this for now:

If you create system from it you will be able to see simple spring constrained particle that will follow motion of emitter.

Now lets create module with basic logic for our rope.
The point is to set Pendulum Pivot to be the end of previous particle.

  1. Lets create new Niagara Module Script and call it NGMS_FindTip.

  2. Set usage flags to Particle Update and don’t forget to expose it to library:

11

  1. First of all we will need to get information about previous particle in chain so lets add ParticleAttributeReader for it, and call it something like RopeAttributeReader (i did mine with Emitter namespace)

  2. Now we are able to read attributes from previous particles by getting its index and subtracting 1:

  1. Lets add module input variable for approximate ParticleLength and make some calculations to get final position vector of particle tip:

  1. Now only thing left is to set our first particle tip to be emitter position and create new variable to set our TipPosition vectors :

Overall node should look like this:

Lets get back to our emitter.

  1. Now we can add our new module into Particle Update:

  1. After that we need to set our RopeAttributeReader parameter to reference our emitter:

  1. Immediately you will see errors because we didn’t specify Emitter Name, so lets fix it:


(also you should compile once to get rid of ! sign, which might left even after fix)

  1. After that, all is left is update some parameters inside Pendulum setup and Calculate Accurate Velocity modules:

24

Alright now everything should work and you can test our rope inside your level:

I know it doesnt provide some real physics, but its a good point to start from. Hope you enjoyed!

61 Likes

Wow, really cool stuff, thanks for sharing!
Super happy to see more Niagara Script content these days.

Out of curiosity, what would the main differences be between using a rope in Niagara vs using spline physics? Are there different implementations that would make one better than the other?

Guessing just easier to do other Niagara related things, such as forces, emit particles from each link if you wanted, anything really :smiley:

1 Like

Yeah @HowardM said everything right. This tutorial wont give you perfect rope physics - the thing is that you can use this tutorial as starting point for some complex effect, or use it in completely different way to grow trees for example, or other stuff)

2 Likes

Okay great thank you that clears it up. Of course, I am now imagining trees dangling like ropes, but it definitely helps :laughing:
@HowardM

Very cool stuff, I made an extremely similar behavior using a custom dynamic input and the maintain distance between points module, but the problem with both of these is that the rope points dont really have a nice inertia like you’d expect (like we can see in the niagara youtube video where the lead tech guy shows that kind of behavior off - how did he do that???)
If you find more out Id be very interested to hear!

This is so cool, I can’t wait for more documentation so I can get a solid grasp on Niagara and scripting. I was wondering though if this could be used for tail simulations with a local transform?

I seem to have run into a snag and I can’t see anything when I put the module in


How dumb am I?

I cant see your node network due to the resolution, so it’s hard to tell if your script is off or not.
Also, make sure you don’t have anything funny going on with your Position in Initialize Particle module as i know OP doesn’t use it in his example. Lastly, have you checked the usual Local/World Space params?

1 Like

As i can see from your module screenshot you created local vector instead of global one for TipPosition. Local variables are working only inside your module(like local variables in functions), so you cant link them after.

https://imgur.com/BqPtssh

Make sure to update pendulum and velocity parameters with this new TipPosition vector, after you added new module, as you can see in last step.

1 Like

Awesome tutorial!

Teeny tiny remark
you don’t actually need to make int32, you can add int32 inputs to the subtract node and just fill it in.
I believe that should do the same thing, but it is neater than the swivle nodes.
image

3 Likes

Nice, thank you! Good to know)

That was it, thanks for coming to my rescue! (Still getting my head into a scripting mind space)

I can’t thank you enough for sharing your knowledge!

Great tutorial!! Has anyone gotten this to work? I followed tutorial letter by letter (twice) and I can’t get particles to draw.

Great!!! has anyone tried, starting from this tutorial, to connect and have two controls at the ends with a single rope?

Hi, first off super cool work, thank you very much!
I’m extra new to Niagara so I must have missed something but I can’t find what for hours now ( tried to restart and remake).

Issue: RopeAttributeEmitter isn’t exposed in the Niagara system’s Emitter Attributes (I checked the expose to library)… Maybe worth to note I updated to 4.25.3 today.

Attached a screenshot

@pirate_sheep sorry i’ve messed the order of steps - first you need to add module, then attributes will be exposed so you can use them.

Other thing that maybe better is to make AttributeReader set to Particle instead of Emitter namespace - if you do that, then you will be able to set EmitterName in same module and could skip this step completely:

image

2 Likes

@kmskazka thank you, works like a charm!

1 Like