Certainly! In Unreal Engine, using the Niagara System is a great way to set up more complex particle interactions like simulating water extinguishing fire. Below, I’ll guide you through creating two Niagara Systems: one for water and one for fire. We’ll set them up to interact with each other through collision events without relying on the individual Emitters directly.
Step 1: Create a Water Niagara System
-
Create a New Niagara Emitter:
- Right-click in the Content Browser.
- Select
FX → Niagara Emitter → Create Blank Emitter.
- Name it
WaterEmitter.
-
Open the Water Emitter:
- Double-click on
WaterEmitter.
-
Add Required Modules:
- Particle Spawn:
- Set particles to spawn continuously. For example, set
Count to 100 per second.
- Particle Size:
- Set a size for your water particles, e.g., size between 0.1 and 0.3.
- Life Cycle:
- Set a lifespan for the particles (e.g., 5 seconds).
- Color Over Life:
- Set color from transparent blue to completely clear to represent water.
- Add Collision Module:
- Add a Collision module to enable collision. Enable
Generate Collision Events to create events when particles collide with other objects.
- Set the
Response to Block.
-
Save the Emitter:
- Save and close
WaterEmitter.
-
Create a New Niagara System:
- Right-click in the Content Browser.
- Select
FX → Niagara System → Create Blank System.
- Name it
WaterSystem.
- Add the
WaterEmitter you created to this system.
-
Adjust System Properties:
- Ensure it’s set up to loop continuously.
Step 2: Create a Fire Niagara System
-
Create a New Niagara Emitter:
- Right-click in the Content Browser.
- Select
FX → Niagara Emitter → Create Blank Emitter.
- Name it
FireEmitter.
-
Open the Fire Emitter:
- Double-click on
FireEmitter.
-
Add Required Modules:
- Particle Spawn:
- Set particles to spawn continuously, for example, 50 per second.
- Particle Size:
- Set to a larger size compared to water (e.g., 0.3 to 0.6).
- Life Cycle:
- Set a shorter lifespan for fire (e.g., 3 seconds).
- Color Over Life:
- Set color from bright orange/yellow to transparent.
- Add Collision Module:
- Add a Collision module and ensure
Generate Collision Events is checked for detecting hits with water.
- Set the
Response to Block.
-
Save the Emitter:
- Save and close
FireEmitter.
-
Create a New Niagara System:
- Right-click in the Content Browser.
- Select
FX → Niagara System → Create Blank System.
- Name it
FireSystem.
- Add the
FireEmitter you created to this system.
-
Adjust System Properties:
- Ensure it’s set to loop continuously.
Step 3: Setting Up Collision Logic in Fire System
Now to implement the logic that allows the fire to interact with water when they collide:
-
Open FireEmitter:
-
Add a Collision Event:
- In the Emitter Update section, add the Event Handler by right-clicking and selecting Add Module → Event → Collision Event.
- Enable it to accept collision events.
- Within the Collision Event module:
- Adjust settings to handle the collision appropriately (see hit state).
-
Add Damage Logic:
-
After the Collision Event, create logic to adjust the particle's properties or lifespan upon collision with water. This could be done by accessing Event data, where you can check the collider and identify if it's water.
-
Add a Set Variable node, and create a new Float variable, like FireHealth, and subtract damage from it when it collides with the water (e.g., a value like 10).
Step 4: Implement Interaction Logic in Blueprint
Now that you have set up the two Niagara Systems and the basic collision detection, let’s put them into an Actor Blueprint to enable them in the world.
-
Create a New Actor Blueprint:
- Right-click in the Content Browser and select
Blueprint Class.
- Create a new Actor and name it
WaterFireManager.
-
Open the Actor Blueprint:
- Open the
WaterFireManager blueprint.
-
Add Niagara System Components:
- In the Components panel, add two Niagara System components: one for
WaterSystem and another for FireSystem.
- Set the
Niagara System component settings:
- Assign
WaterSystem to one and FireSystem to the other system.
-
Setup Event Logic:
- In the Event Graph, on Begin Play, you can start/activate both systems to ensure they are visible in the game.
- You can also add logic to retrieve health and handle deactivation:
- Use a boolean check to deactivate or destroy the fire if its health is less than or equal to zero after a collision.
Sample Blueprint Logic
-
Begin Play:
- On Event Begin Play, Activate both systems.
Event Begin Play
→ Activate(WaterSystem)
→ Activate(FireSystem)
-
Event Handling:
- Create a Timer or a similar loop to check the health status of fire particles and deactivate them when needed:
Event Tick
→ If (FireHealth <= 0)
→ Deactivate(FireSystem)
Step 5: Testing the Interaction
-
Drag Your Actor into the Level:
- Go to your level and drag the
WaterFireManager Actor into your scene.
-
Play the Scene:
- Click Play in the Editor.
- Observe your water particles colliding with fire particles.
- The fire particles should extinguish based on your set conditions.
Conclusion
By following these steps, you will have created two Niagara Systems fully equipped to interact with each other in Unreal Engine 5.4. The water particles should effectively decrease the "health" of the fire particles when they collide, visually representing the effect of water extinguishing fire. Feel free to adjust parameters, colors, sizes, and lifetimes to refine the effects further! If you have any additional questions or need help with specific elements, feel free to ask!