Search Unity

Impulse/shake inconsistency help please!

Discussion in 'Cinemachine' started by Mctuggernuts25, Jul 9, 2020.

  1. Mctuggernuts25

    Mctuggernuts25

    Joined:
    May 26, 2020
    Posts:
    8
    Hey Team!

    I have an impulse listener extension on the Cine Machine Camera. I then have a impulse source on my player in which I trigger a 6D shake from a script. However the shake gets increasingly more intense the more I travel on the X Axis and I cant for the life of me get it to be consistent.

    Thanks in advance for any help!
     
  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Hi
    I created a test now using the 6D Shake. I did not see the shake get more intense overtime.

    What do you mean exactly?
     
  3. Mctuggernuts25

    Mctuggernuts25

    Joined:
    May 26, 2020
    Posts:
    8
    Hey!

    So, I have the 6d shake triggered when my player lands his jump (triggered by an animation event). To trigger it, i have my own script that calls the API 'generateimpulse' method which is of course part of the cinemachine impulse source script attached to the player.

    If i jump at 0 on the X-axis, its normal. If i jump at 20, its crazy. Then at 60 on the X-axis its insanely shakey. if i then move the player back to 0, the shake goes back to normal. so its something to do with positioning.

    I have tried altering all inspector settings for the impulse source to no avail.

    Hope this info helps.
     
    Last edited: Jul 10, 2020
  4. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Could you post the code please?

    Post a screenshot of your impulse source setup please.

    Got it, thanks. :)
     
  5. Mctuggernuts25

    Mctuggernuts25

    Joined:
    May 26, 2020
    Posts:
    8
    Hey, Sure! Sorry, Im not completely familiar with the formatting on the forum but below is the trigger code and the photo of the impulse source inspector. Just to reiterate that method is triggered by an animation event and the code is attached to the player as well as the impulse source.

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using Cinemachine;

    public class CineMCreateImpule : MonoBehaviour
    {
    [SerializeField]
    CinemachineImpulseSource cSource;

    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {

    }

    void CreateImpules()
    {
    cSource.GenerateImpulse(transform.position);
    }
    }
     

    Attached Files:

    gaborkb likes this.
  6. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    The problem is here. Instead of the position, you should instead add a vector representing a direction. For example, (player.position - transform.position).normalized * impulseSpeed.

    This is the function signature for reference:
    Code (CSharp):
    1. /// <summary>Broadcast the Impulse Signal onto the appropriate channels, using
    2. /// a custom impact velocity, and this transfom's position.</summary>
    3. /// <param name="velocity">The impact magnitude and direction</param>
    4. public void GenerateImpulse(Vector3 velocity)
    5. {
    6.     GenerateImpulseAt(transform.position, velocity);
    7. }

    Check out our example scenes, they show how to use impulses with collisions and how impulses are propagated. The examples are called 'Impulse' and 'ImpulseWave'. You can import our examples from the package manager.
     

    Attached Files:

  7. Mctuggernuts25

    Mctuggernuts25

    Joined:
    May 26, 2020
    Posts:
    8
    Ahh, ok. Great! Thank you very much for your help. I am away from my PC until tomorrow evening so I will try it then and reply further if I have issues. Hopefully, I should be ok because I understand what you mean.

    Thanks!