Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    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:
    13
    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,319
    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:
    13
    Thanks Greg!