|
Hi, I have a particle emitter that has a world particle collider attached to it, "send collision message" is enabled. I have a box with a mesh collider and rigidbody aswell as this script attached to it... The particle is definitely hitting the box but its not moving the rigidbody what so ever. Any idea why this is? Thanks.
(comments are locked)
|
|
This script must be attached to the particle system, not to the rigidbody. If you want to add a script to the rigidbody instead, it should be:
function OnParticleCollision (other : GameObject){
var direction : Vector3 = transform.position - other.transform.position;
rigidbody.AddForce (direction.normalized * 5);
}
The main difference between both versions: in the first version (particle script), any rigidbody will be affected by this particle system; in the 2nd version (rigidbody script, like above), this rigidbody will be affected by any particle system that has World Particle Collider and Send Collision Message enabled. Thanks Aldo, I tried both methods, the first didnt seem to work, but when i attached the second script to the rigidbody as you suggested it worked perfectly. Thanks.
May 19 '12 at 11:16 PM
Lboy
(comments are locked)
|

@coolkid808 It might not be enough force to move your object, have you tried increasing the force value from 5 to something extreme like say...1000. If your player still does not move, there is another problem(unless your players mass is really high). Have you debugged from inside the function to ensure a collision is happening? Put a debug log or print inside of the conditional if(body){ } and see if it prints to the console.
Thanks hijinx but i followed aldo's method and it fixed the problem