Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Cinemachine Impulse Listener on player object?

Discussion in 'Cinemachine' started by zt3ff3n, Jul 4, 2018.

  1. zt3ff3n

    zt3ff3n

    Joined:
    Feb 19, 2016
    Posts:
    15
    I'm using the freelook rig as a mainly top-down camera looking at my player-object from a higher Y-axis offset.
    I'd still like it to shake whenever the player shoots, is close to an explosion etc. I can only seem to attach the Impulse Listener onto the virtual camera, which makes it shake if the camera is close to an explosion etc. How do I go about controlling the shake with the magnitude an all that lovely juice - only based impulses near the player-object?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,740
    You can do it very easily with a custom impulse Listener.

    Find CinemachineImpulseListener.cs, copy it into your Assets folder, and rename it to ImpulseListenerAtTarget, or something like that. Rename the class name to match.

    Then, look inside where it calls CinemachineImpulseManager.Instance.GetImpulseAt(), and instead of passing it State.FinalPosition as the listener location, change it to pass it the player's position. Use the new extension in place of CinemachineImpulseListener, and you will get the behaviour you're looking for.
     
  3. zt3ff3n

    zt3ff3n

    Joined:
    Feb 19, 2016
    Posts:
    15
    Thanks Greg!