This page lists a few 'recipes' that will teach you in a few steps how to do common tasks using Feel

Introduction

Want to get started quickly with Feel? This page contains simple steps you can follow for a number of basic situations, no explanations, just quick steps. Don’t hesitate to check the rest of the documentation to learn more about how the engine works. And if you’re wondering how to achieve something, or would like to see a particular recipe on this page, don’t hesitate to make suggestions!

Note that most of these will provide Feel / Unity versions, that’s just to provide the context they were first written in. But it’s safe to assume that they should work on any higher versions of both Unity and Feel.

How to use MMFeedbacks to trigger a particle system?

  • in Unity 2019.4.26f1, create a new project
  • from the Package Manager, import Feel v2.1
  • create a new scene
  • create a new empty object in it, add a particle system component to it
  • let’s make it a bit prettier, under its Renderer panel, click on the Material dot on the right of the field, and pick the FeelSnakeEatParticleMaterial
  • under its Emission foldout, set RateOverTime to 0, and add a Burst instead by pressing the little “+” under Bursts (default settings will do)
  • towards the top of the inspector, set the StartLifetime to 0.5
  • then check SizeOverLifetime down in the list of foldouts, and set its size curve to any of the default downward curves
  • if you were to play your particle system, you should see a bunch of bubbles shrinking down rapidly
  • now create a new empty object, call it MyTestFeedbacks, add a MMFeedbacks component to it
  • add a ParticlesPlay feedback to it, and drag the particle system you’ve created into its BoundParticleSystem slot
  • press play in your editor, then select your MyTestFeedbacks object, and in its MMFeedbacks inspector, press the green Play button
  • now you know how to trigger particle systems via MMFeedbacks. Note that there are other ways to do it, for example you could decide to make a prefab out of your particle system, and instead use the ParticleInstantiation feedback

How to setup a regular, non-Cinemachine camera shake

  • in Unity 2019.4.26f1, create a new project
  • from the Package Manager, import Feel v2.1
  • create a new empty scene
  • add a cube, position it at 0,0,0
  • create an empty game object at the camera’s position, call it CameraRig
  • create an empty game object at the camera’s position, call it CameraShaker, nest it under CameraRig
  • nest your Camera under CameraShaker (you should have CameraRig > CameraShaker > MainCamera)
  • on your CameraShaker node, add a MMCameraShaker component
  • on its MMWiggle, check Position, select Noise as wiggle type, uncheck wiggle permitted
  • create an empty game object, call it MyTestFeedbacks, add a MMFeedbacks component to it
  • add new feedback > camera > camera shake
  • press play, then Play on your MyTestFeedbacks inspector, camera will shake

How to setup a Cinemachine camera shake

  • in Unity 2019.4.26f1, create a new project
  • from the Package Manager, import Feel v2.1
  • from the Package Manager, import Cinemachine
  • create a new empty scene
  • add a cube, position it at 0,0,0
  • via the Cinemachine menu in the top menu, create a new virtual camera
  • select your virtual camera, and via its AddExtensions dropdown, add an impulse listener
  • create an empty game object, call it MyTestFeedbacks, add a MMFeedbacks component to it, position it at 0,0,0
  • add a new Cinemachine Impulse feedback to it, via its “Add new feedback” dropdown
  • from its inspector, click the little cog at the end of the RawSignal field and select Presets > 6D Shake
  • set its Velocity (at the bottom of the inspector) to 5,5,5
  • press play in the editor, select the MyTestFeedbacks object, and in its MMFeedbacks inspector, press the green Play button
  • CAMERA SHAKE!

How to use Feel with URP?

  • in Unity 2019.4.26f1, create a new project using the URP template
  • from the Package Manager, import Feel v2.1
  • that’s it, you can now use Feel with your URP project

Ok and how to use MMFeedbacks with URP volumes then?

  • after the steps described above :
  • create a new scene
  • in it, add a cube, position it at 0,0,0
  • create a new global volume (right click, volume > global volume in your Hierarchy panel)
  • press the New button next to Profile in its inspector
  • add an override to it, pick Vignette, set the Vignette’s intensity to 0.5
  • add a new component to the global volume, in the add component menu type MMVignetteShaker_URP
  • select the MainCamera, in its inspector under Rendering, check PostProcessing
  • you should now see the Vignette in your Game view
  • create an empty game object, call it MyTestFeedbacks, add a MMFeedbacks component to it
  • press the “add new feedback” dropdown and select PostProcess > Vignette URP
  • in its inspector, set Remap Intensity Zero to 0.5
  • press play in the editor, select the MyTestFeedbacks object, and in its MMFeedbacks inspector, press the green Play button
  • now you know how to trigger volume feedbacks. To target other post processing filters, make sure you add the corresponding Shaker on the Volume

How to change a feedback’s property via script at runtime?

For plenty of reasons, you may want to change a property or more on a feedback at runtime. It’s of course possible, and in this example we’ll see how we can change the intensity of a Chromatic Aberration feedback in the Duck demo. It’d be the exact same logic for any other property, on any other feedback.

  • in Unity 2019.4.28f1, create a new project
  • from the Package Manager, import Feel v2.3
  • open the FeelDuck demo scene
  • create a new, empty gameobject, call it RuntimeTest
  • outside of the Feel folder, create a new C# script, call it RuntimeTest, and paste the following in it :
using MoreMountains.Feedbacks;
using MoreMountains.FeedbacksForThirdParty;
using MoreMountains.Tools;
using UnityEngine;

public class RuntimeTest : MonoBehaviour
{
    public MMFeedbacks TargetFeedback;
    [Range(-100f, 100f)]
    public float Intensity = 0f;
    [MMInspectorButton("TestFeedback")]
    public bool PlayFeedbackBtn;

    private MMFeedbackLensDistortion _lensDistortion;

    private void Start()
    {
        // on start we store our lens distortion feedback component, so that we can target it later on
        _lensDistortion = TargetFeedback.GetComponent<MMFeedbackLensDistortion>();
    }

    public void TestFeedback()
    {
        // we modify our RemapIntensityOne value before playing our feedback. This is done like for any other public attribute on any component in Unity
        if (_lensDistortion != null)
        {
            _lensDistortion.RemapIntensityOne = Intensity;
        }
        // we then play our MMFeedbacks
        TargetFeedback?.PlayFeedbacks();
    }
}
  • then add that script to your RuntimeTest game object
  • select your RuntimeTest object, and drag the FeelDuckLandingFeedback object from your Hierarchy panel into the RuntimeTest’s TargetFeedback slot in its inspector
  • press play in the editor, then select your RuntimeTest object, change the intensity value in your inspector, and press the TestFeedback button, every time you’ll play, the value you’ve changed in the inspector will be sent to the feedback before it plays

One important thing to keep in mind when changing values at runtime is that some of them will get cached for performance reason. So always double check that the value you’re interacting with doesn’t get cached at some point, and that you’re targeting the correct property, or resetting the cache if needed.

How to setup a camera zoom feedback?

  • in Unity 2019.4.26f1, create a new project
  • from the Package Manager, import Feel v2.1
  • from the Package Manager, import Cinemachine
  • create a new empty scene
  • add a cube, position it at 0,0,0
  • select your MainCamera, add a MMCameraZoom component to it
  • create an empty game object, call it MyTestFeedbacks, add a MMFeedbacks component to it
  • add a Camera > Camera Zoom feedback to it, via its “Add new feedback” dropdown
  • press play in the editor, select the MyTestFeedbacks object, and in its MMFeedbacks inspector, press the green Play button

How to trigger MMFeedbacks via the Timeline

  • in Unity 2019.4.26f1, create a new project
  • from the Package Manager, import Feel v2.1
  • for this example we’ll open the FeelDuck demo scene
  • create a new empty object, call it Director
  • open the Timeline panel (Window > Sequencing > Timeline)
  • in the Timeline panel, press the Create (a director) button, call the new asset TimelineDirector, save it in your project
  • drag the FeelDuckBackground into the Timeline, and pick “Add activation track”
  • copy the Active block, move the new one to the right, you should now have two Active blocks, maybe with a bit of a gap between them, that’s our Timeline animation (it’ll activate/disable/activate the background, of course you may want to do more fancy stuff in your own Timeline, that just gives us a track to play)
  • press the little pin icon under the frame count to reveal our markers track
  • around frame 120, right click in the marker track and select “Add signal emitter”
  • in the inspector, click on Create Signal, name the new asset “TestMMFeedbacks.signal”, save it in your project
  • in the inspector, click on “Add signal receiver”
  • select your Director object, and in its inspector, drag the FeelDuckJumpStartFeedback into the SignalReceiver’s event reaction slot, select its MMFeedbacks > PlayFeedbacks() method as its reaction
  • press play in the editor, then press play in your timeline, your feedback will play everytime the play head passes the marker
  • don’t hesitate to check https://blog.unity.com/technology/how-to-use-timeline-signals to learn more about how Timeline and Signals work

How to trigger a MMFeedbacks with Playmaker?

Note : there are plenty of other ways to do it, and this will also (most of the time) be the same general logic for Bolt and other visual scripting tools.

  • create a new project in Unity 2019.4.28f1
  • import Feel v2.3
  • install Playmaker
  • in a new scene, create an empty object, call it MyFeedbacks, add a MMFeedbacks component to it
  • add a Debug Log feedback to it, set its Debug Message to “Hello!”
  • open the Playmaker editor, right click in it to add a FSM
  • rename that first state to “GettingInput”, and using the Action Browser, add a GetKeyDown action, set its key to F2
  • in the Send Event dropdown, select New Event, name it “F2Pressed”, and press the CreateEvent button, then click on the red label to add transition to state
  • right click in the FSM to add a new state, call it “PlayingFeedbacks”
  • right click on the first state’s F2Pressed event, set its transition target to PlayingFeedbacks
  • right click on the PlayingFeedbacks state, add transition > Finished, then right click on Finished and set its transition target to GettingInput
  • press play in your Unity editor, now every time you’ll press F2, the feedback will play, and “Hello!” will appear in the console. Any other feedbacks you’d add to your MyFeedbacks MMFeedbacks will of course also play

How to use the MMHealthBar component to automatically draw health bars?

  • create a new project in Unity 2019.4.28f1
  • import Feel v2.3
  • create a new, empty scene
  • create a cube, position it at 0,0,0
  • add a MMHealthBar component to it
  • press play, you’ll notice the healthbar gets drawn above your cube
  • if you now want to interact with your MMHealthBar and update it, you’ll need to pass it data to update it. We’ll use a script to do so.
  • create a new C# class, call it TestMMHealthBar, and paste the following in it :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Tools;

/// <summary>
/// A simple class used to interact with a MMHealthBar component and test it
/// To use it, add it to an object with a MMHealthBar, and at runtime, move its CurrentHealth slider, and press the Test button to update the bar
/// </summary>
public class TestMMHealthBar : MonoBehaviour
{
    [Range(0f, 100f)]
    public float CurrentHealth = 50f;

    protected float _minimumHealth = 0f;
    protected float _maximumHealth = 100f;
    protected MMHealthBar _targetHealthBar;

    [MMInspectorButton("Test")] public bool TestButton;

    protected virtual void Awake()
    {
        _targetHealthBar = this.gameObject.GetComponent<MMHealthBar>();
    }

    public virtual void Test()
    {
        if (_targetHealthBar != null)
        {
            _targetHealthBar.UpdateBar(CurrentHealth, _minimumHealth, _maximumHealth, true);    
        }
    }
}
  • add this component to your Cube, press play, and at runtime, move its CurrentHealth slider in its inspector. Every time you press the Test button, the health bar will update.

How to setup floating texts to play them via feedbacks?

  • in Unity 2019.4.26f1, create a new project
  • from the Package Manager, import Feel v2.2
  • in an empty scene (or your scene), create a new empty gameobject, name it “FloatingTextSpawner”, add a MMFloatingTextSpawner component to it.
  • in your project panel, search for the MMFloatingText prefab, and drag it into the newly created spawner, under its Pooler settings, in the PooledSimpleMMFloatingText slot
  • create a new empty object, call it “TestFeedbacks”, add a MMFeedbacks component to it
  • add a new UI > Floating Text feedback to it
  • press play, play your feedback, you’ll see a “100” text spawn every time
  • to go further, you can check the “use intensity as value” to have it apply your MMFeedbacks’ intensity to the feedback
  • you can also dynamically change the Value attribute of that MMFeedbackFloatingText component to anything you want
  • you can also use events from anywhere in your code to have the spawner emit new floating texts, using the MMFloatingTextSpawnEvent. You’ll see an example of such an event call in the MMFeedbackFloatingText class, it’s a one line call.

How to make an object wiggle in your scene?

  • in Unity 2019.4.28f1, create a new project
  • from the Package Manager, import Feel v2.5.1
  • in a new scene, create a cube
  • add a MMWiggle component to it
  • check the Position checkbox, set its Wiggle Type to Noise, press play, you now have a wiggling cube
  • you can now increase the frequency, amplitude, or add a shift (useful if you have more than one of these), and play with all the other options

The MMBlink component will let you define blinking sequences on objects, and you can then use a MMBlink MMFeedback to trigger it. Here’s one way to set it up :

  • in Unity 2019.4.29f1, create a new project using the standard RP
  • from the Package Manager, import Feel v2.4.1
  • in a new scene, create a new sprite renderer, set its sprite to “button-A” (or any sprite of your choice)
  • add a MMBlink component to it, set its Method to Material Alpha, and drag the Sprite Renderer into the MMBlink’s TargetRenderer slot
  • then we’ll want to define our blink sequence, set the Phases array’s size to 2
  • under the array’s Element 0, set PhaseDuration to 1, OffDuration to 0.3, OnDuration to 0.7
  • under the array’s Element 1, set PhaseDuration to 0.5, OffDuration to 0.2, OnDuration to 0.3
  • set the Repeat Count to -1 (which will have it repeat forever)
  • press play, the sprite will now blink in repeating patterns

Now to have a MMFeedbacks trigger it :

  • uncheck Blinking on the MMFeedbacks, and set the RepeatCount to 5
  • create a new empty game object, call it MyTestFeedbacks
  • add a new feedback (renderer > MMBlink), and drag the MMBlink object into its TargetBlink slot
  • press play in your editor, then press Play on the MyTestFeedbacks’ inspector’s test button, the sprite will blink for 5 sequences

The MMBlink component offers quite a few options, letting you blink objects by enabling/disabling objects, playing on their alpha, emission, or simply any float on their material’s shader. You can also have it lerp these values (change the Element0 and Element1’s On/Off Lerp Durations to 0.5 to test that)

How to play a random sound with randomized volume?

  • create a new project in Unity 2019.4.28f1
  • import Feel v2.3
  • create a new scene, open it
  • create an empty object, add a MMSoundManager to it
  • create another empty, add a MMFeedbacks to it
  • add a MMSoundManager Sound feedback to it
  • set its random sfx array size to 2, set the first element to FeelBlobNote1, the second to FeelBlobNote2
  • set the min volume to 0.2, max volume to 0.5
  • press play in the editor, then press the green Play button at the bottom of your MMFeedbacks, everytime you’ll play a new volume will be randomized

How to add a button to mute all sounds?

  • in Unity 2019.4.26f1, create a new project
  • from the Package Manager, import Feel v2.2
  • in a scene containing a MMSoundManager
  • create a UI button, press “+” on its OnClick action, drag your MMSoundManager in that slot, and select the MuteMaster method
  • press play, pressing the UI button will mute all sounds playing through the MMSoundManager
  • note that you can also do that via a MMFeedback (MMSoundManager Track Control, or MMSoundManager All Sounds Control), and you can also decide to save this setting via a feedback, see http://feel-docs.moremountains.com/mmsoundmanager.html for more info on that!