- Home /
How reliable is particle collision?
Hello
I'm using the legacy particles with a world particle collider and I'm wondering if A)The collision is accurate or B) I'm doing it wrong.
I have a sphere object which is a placeholder for my enemy; on the sphere I have attached a rigidbody,sphere collider and the enemy script. When the enemy is enabled it simply moves towards the player using this line of code in the Update() method :
Vector3 pos = (transform.position - player.transform.position).normalized; // Get the direction to move
transform.Translate(-pos * speed * Time.deltaTime);
I tried using doing it with AddForce in FixedUpdate() and got some very strange results with seemingly random moving objects.
The particle emitter is instantiated (That's the only way I could get it to work, can I not use the Emit() method?) in when the player clicks to shoot and spawns only 1 particle. The size of the particle is 3, it just wouldn't collide with the sphere gameobject at smaller sizes. If a particle hits the enemy it calls the OnParticleCollision() method which calls another method within the enemy script and destroys the enemy. As the game progresses the speed of the enemies increase and eventually it gets to a point where the particle simply goes straight through the sphere.
I set the enemy rigidbody to interpolate and collision detection to continuous dynamic and noticed no change really.
I know this covers a few questions, but they are all related for my project and I've spent quite a bit time searching with no solid answers.
What I would like to know
Is there a better way to move my enemies?
Should I use the old particle system or can this be done with the shuriken system?
Am I using the correct methods to detect the collision or what is the best way for fast moving objects?
Can this be done with AddForce()? I thought this gave a smoother looking movement.
I tried using raycast to detect the collision, but found it very difficult to make it look like the bullet effect hit the enemy before it was destroyed.
Answer by Owen-Reynolds · Feb 08, 2013 at 03:12 AM
Moving with transform.Translate
messes up physics. It's like dragging it yourself in Scene mode while the game plays. It sort of works if you move less than the collision error -- the physics step will notice and will push them apart.
The particle colliders are mostly just for special effects. It's, as best I know, not full-blown collision, with all the time that would take. Best way to fire a "particle" at something is to fire a regular rigidbody + collider, then attach (child?) a particleSystem to that. Then you can adjust the invisible collider to be as big as you need.
The first time I made this game I used a collider that was enabled when the player shoots and got fired towards the enemy, looks like that is the best way to go.
Thanks!
Your answer
![](https://koobas.hobune.stream/wayback/20220613092330im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Extinguish fire with water particle system 0 Answers
Initialising List array for use in a custom Editor 1 Answer
Illuminating a 3D object's edges OnMouseOver (script in c#)? 1 Answer