- Home /
Question by
Taimoor Ali · Apr 21, 2015 at 12:06 PM ·
collisionparticleeffect
How do i fix this code..!!!
using UnityEngine;
namespace UnitySampleAssets.Effects
{
public class WaterHoseParticles : MonoBehaviour
{
private ParticleCollisionEvent [] collisionEvents = new ParticleCollisionEvent[16];
public static float lastSoundTime;
public float force = 1;
private void OnParticleCollision(GameObject other)
{
int safeLength = GetComponent<ParticleSystem>().GetSafeCollisionEventSize();
if (collisionEvents.Length < safeLength)
{
collisionEvents = new ParticleSystem.CollisionEvent[safeLength];
}
int numCollisionEvents = GetComponent<ParticleSystem>().GetCollisionEvents(other, collisionEvents);
int i = 0;
while (i < numCollisionEvents)
{
if (Time.time > lastSoundTime + 0.2f)
{
lastSoundTime = Time.time;
}
var col = collisionEvents[i].collider;
if (col.attachedRigidbody != null)
{
Vector3 vel = collisionEvents[i].velocity;
col.attachedRigidbody.AddForce(vel*force, ForceMode.Impulse);
}
other.BroadcastMessage("Extinguish", SendMessageOptions.DontRequireReceiver);
i++;
}
}
}
}
It keeps giving me this Error"Assets/SampleAssets/Effects/ParticleSystems/scripts/WaterHoseParticles.cs(18,54): error CS0426: The nested type CollisionEvent' does not exist in the type
UnityEngine.ParticleSystem' "
Any suggestions
Comment
Answer by SamTheT · Apr 21, 2015 at 12:09 PM
You found an answer yourself, errors says, that there is no collisionEvent in particle system
Your answer
![](https://koobas.hobune.stream/wayback/20220613193648im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Collision detection problems with plane + 2D Sprites 0 Answers
Fist Punch Collision 0 Answers
handling collision with two objects of the same tag 1 Answer
Object gravity but no collisions 0 Answers
Manual Collision Detection... 2 Answers