public void ExplosionImpulse(Vector3 pos, float mult = 1f)
    {
        explosionImpulse.transform.position = pos;
        Vector3 veclocity = pos - transform.position;

        explosionImpulse.GenerateImpulseAt(pos, veclocity.normalized * mult);
    }
Esempio n. 2
0
    public void Shake(Settings shake, bool force = false)
    {
        if (force || Time.time > (lastShakeTime + MinDelay))
        {
            DebugLog($"Shake : {shake.Position} : {shake.Intensity} {(force ? "(Forced)" : "")}");
            lastShakeTime = Time.time;

            Vector3 ShakeVector = new Vector3(Random.value - 0.5f, Random.value - 0.5f, Random.value - 0.5f).normalized *shake.Intensity;

            if (CinemachineImpulseSource != null)
            {
                DebugLog($"CinemachineImpulseSource.GenerateImpulseAt({shake.Position},{ShakeVector})");
                CinemachineImpulseSource.GenerateImpulseAt(shake.Position, ShakeVector);
            }

            foreach (var reciever in m_Recievers)
            {
                reciever.Shake(shake, Attenuation);
            }

            if (EnableAudioShake && shakeAudioSource != null)
            {
                shakeAudioSource.transform.position = shake.Position;
                shakeAudioSource.Play();
            }
        }
    }
Esempio n. 3
0
        public override void OnVFXOutputEvent(VFXEventAttribute eventAttribute)
        {
            if (cinemachineImpulseSource != null)
            {
                Vector3 pos = eventAttribute.GetVector3(k_Position);
                Vector3 vel = eventAttribute.GetVector3(k_Velocity);

                if (attributeSpace == Space.Local)
                {
                    pos = transform.localToWorldMatrix.MultiplyPoint(pos);
                    vel = transform.localToWorldMatrix.MultiplyVector(vel);
                }

                cinemachineImpulseSource.GenerateImpulseAt(pos, vel);
            }
        }
Esempio n. 4
0
 void Shake(NoteEnum n)
 {
     impulseSource.GenerateImpulseAt(Vector3.one, Vector3.one * ShakeStrength);
 }
Esempio n. 5
0
        public override void Execute(GameObject instigator = null)
        {
            if (impulseSource == null)
            {
                Debug.LogWarning($"CinemachineCameraShakeAction : No Impulse source was provided");
                return;
            }

            Vector3 impulse = baseImpulse;

            if (randomImpulse)
            {
                impulse += new Vector3(Random.Range(-variation.x / 2, variation.x / 2), Random.Range(-variation.y / 2, variation.y / 2), Random.Range(-variation.z / 2, variation.z / 2));
                if (normalize)
                {
                    impulse.Normalize();
                    impulse *= Random.Range(postNormalizeRemap.x, postNormalizeRemap.y);
                }
            }

            switch (impulseLocation)
            {
            default:
            case ImpulseLocation.Self:
                if (localSpace)
                {
                    impulse = transform.localToWorldMatrix.MultiplyVector(impulse);
                }

                impulseSource.GenerateImpulseAt(transform.position, impulse);
                break;

            case ImpulseLocation.ImpulseSource:
                if (localSpace)
                {
                    impulse = impulseSource.transform.localToWorldMatrix.MultiplyVector(impulse);
                }

                impulseSource.GenerateImpulseAt(impulseSource.transform.position, impulse);

                break;

            case ImpulseLocation.OtherTransform:
                if (otherTransform != null)
                {
                    if (localSpace)
                    {
                        impulse = otherTransform.localToWorldMatrix.MultiplyVector(impulse);
                    }

                    impulseSource.GenerateImpulseAt(otherTransform.position, impulse);
                }
                else
                {
                    Debug.LogWarning("CinemachineCameraShakeAction : No RemoteTransform found for setting position, using self transform instead");
                    if (localSpace)
                    {
                        impulse = transform.localToWorldMatrix.MultiplyVector(impulse);
                    }
                    impulseSource.GenerateImpulse(impulse);
                }
                break;

            case ImpulseLocation.InstigatorPosition:
                if (instigator != null)
                {
                    if (localSpace)
                    {
                        impulse = instigator.transform.localToWorldMatrix.MultiplyVector(impulse);
                    }

                    impulseSource.GenerateImpulseAt(instigator.transform.position, impulse);
                }
                else
                {
                    Debug.LogWarning("CinemachineCameraShakeAction : No Instigator found for setting position, using self transform instead");
                    if (localSpace)
                    {
                        impulse = transform.localToWorldMatrix.MultiplyVector(impulse);
                    }
                    impulseSource.GenerateImpulse(impulse);
                }
                break;
            }
        }
Esempio n. 6
0
 public static void ShakeAt(Vector3 position, Vector3 velocity)
 {
     _source.GenerateImpulseAt(position, velocity);
 }
Esempio n. 7
0
 public static void Shake(Vector3 position, Vector3 velocity, float duration = .2f)
 {
     mainImpulseSource.m_ImpulseDefinition.m_TimeEnvelope.m_SustainTime = duration;
     mainImpulseSource.GenerateImpulseAt(position, velocity);
 }