[Niagara 4.25] Rope Physics Mini Tutorial
Hi guys here is a little tutorial of how you can create some rope physics using pendulum constrain.
Create new Niagara emitter with empty template.
Set your Emitter State loop behavior to once and duration to infinite:
- Add Spawn Burst module and set spawn count to 10
- Remove Initialize Particle from Particle Spawn section.
- Uncheck kill particles in Particle State node and set it to it to die when emitter deactivates.
- Remove sprite renderer and add mesh renderer to S_Arrow (from plugin content)
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).
Enable Spring Driven Constraint in Pendulum Setup and update module with those parameters:
- Also Enable Calculate and Output Potential Energy in Pendulum Constraint node.
- Add Orient Mesh to Vector module and set look at direction to be Pendulum Axis:
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.
Lets create new Niagara Module Script and call it NGMS_FindTip.
Set usage flags to Particle Update and don’t forget to expose it to library:
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)
Now we are able to read attributes from previous particles by getting its index and subtracting 1:
- Lets add module input variable for approximate ParticleLength and make some calculations to get final position vector of particle tip:
- 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:
Now lets get back to our emitter.
- Before we add our node we need to set our RopeAttributeReader parameter to reference our emitter:
- 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)
- Now we can add our new module into Particle Update:
- After that, all is left is update some parameters inside Pendulum setup and Calculate Accurate Velocity modules:
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!