I have an enemy with a Character Controller on it. I have also created an empty game object and attached a train particle emitter to it (its a spell). I have the “spell” fire at the enemy just fine and it moves to the enemies position, however I cannot get the OnParticleCollision() to fire off. What am I missing?
-
I have the World Particle Collider on the spell game object and have the “Send Collision Message” checked.
-
I have implemented a OnParticleCollision() on both the spell object and the enemy.
They never get called…?! I am sure I am missing something small, anyone?
I hope the idea is not to have a spell collide like that.
If so: don’t do it, please.
use a collider on the game object you fire, simple sphere collider at best, and use that for collision.
thats two magnitudes faster.
Particle collision only makes sense for things like a rain particle emitter where you want to create splashes where rain drops hit the ground and alike.
Not really…particle collisions only tell you that the particle system collided at all, not where each particle collided.
–Eric
Thanks for input. I have tried both ways and cannot get the collider events to fire. IF and only IF the enemy actually moves towards me and runs though the spells, then it fires. but if they “just” touch they do not seem to fire a collision.
I will layout what I have tried as an alternative.
-
Again I have an empty object which is the “spell”, I have added a Sphere Collider to it.
-
I have added a script to the empty object which detects collisions (onControllerColliderHit).
-
I have added same script to my enemy.
-
when the player clicks the button for that spell, I use this code to move the “spell” at the enemy (I use a Trail Renderer for effect)
Vector3 targetPosition = GlobalManager.CurrentTarget.transform.position + new Vector3(0f,2.0f,0f);
gameObject.transform.LookAt(targetPosition);
Vector3 forward = gameObject.transform.TransformDirection(Vector3.forward);
Vector3 direction = forward * speed;
gameObject.transform.position += direction;
Any reason why I do not get a hit? The Spell seems to move right beside the enemy and sit there (does not collide). If then enemy moves through the spell then it triggers the collision.
Any ideas, Dreamora, Eric?
You’re setting your position by hand which sometimes bypasses collisions entirely. Try moving using rigidbody.velocity instead.
That was related to the issue - I had to add a rigid body to the spell object. Then all was good. =)
now i got the same problem…i have group of cloud particles where each cloud is separated with some distance.i want to hit the cloud with an cube and detect collision detection.ihave used onparticlecollision() attached to the particles but the onparticlecollision script is not working.plz help.chek the can we attach a collider for each particle emitted by a emitter - Questions & Answers - Unity Discussions.