0
\$\begingroup\$

I have this Physics collision metrix(1). I have Player layer on the ship and PlayerShells on Particles whitch's my shooting.

The problem: When I shoot, OnParticleCollision on my shells collides with player, but as you can see on the picture it shouldn't happen.

Proofing my theory, I testet it: (2) and (3) screenshoots;

My "collision" code:

private void OnParticleCollision(GameObject other)
        {
            SetDamage(other.GetComponent<ISetDamage>());
            
            //Creating hit effect
            _mainParticles.GetCollisionEvents(other, _collEvent);
            Vector3 pos = _collEvent[0].intersection;   //hit posotion
            Quaternion newRot =
               Quaternion.Euler(transform.rotation.x, -transform.rotation.y, transform.rotation.z);
               //Tryed to rotate effect like opposite from bullet, but it doesn't work for now

            switch (other.GetComponent<Stats>().GetMatter)
            {
                case Matter.Steel:
                    Instantiate(_hitSteel, pos, newRot);
                    break;
                case Matter.Wood:
                    Instantiate(_hitWood, pos, newRot);
                    break;
                case Matter.Flesh:
                    Instantiate(_hitFlesh, pos, newRot);
                    break;
                case Matter.Dirt:
                    Instantiate(_hitDirt, pos, newRot);
                    break;
                case Matter.Stone:
                    Instantiate(_hitStone, pos, newRot);
                    break;
            }
        }

Physics collision metrix enter image description here enter image description here enter image description here

What am I doing wrong?? :(

\$\endgroup\$
7
  • \$\begingroup\$ Which of these objects has your particle system on it? That doesn't appear to be shown in the screenshots. \$\endgroup\$
    – DMGregory
    Commented Jan 30, 2021 at 15:04
  • \$\begingroup\$ no, it doesn't shown here. It's just screenshots that collisiom metrix works for simple objects. I'll add particles screenshoot \$\endgroup\$
    – Dead Lord
    Commented Jan 30, 2021 at 15:28
  • \$\begingroup\$ If you expand the Collision module on your Particle System, do you see a "Collides With" parameter? \$\endgroup\$
    – DMGregory
    Commented Jan 30, 2021 at 15:35
  • \$\begingroup\$ oh god yes! Didn't see that before! Thank you! \$\endgroup\$
    – Dead Lord
    Commented Jan 30, 2021 at 15:53
  • \$\begingroup\$ Want to post your solution as an answer if it's working for you? (I should also note, I've never used this feature before. I found that by searching "unity particle collision" and just clicking the top few links - so don't underestimate your ability to find this info!) \$\endgroup\$
    – DMGregory
    Commented Jan 30, 2021 at 15:56

1 Answer 1

0
\$\begingroup\$

Here's the answer :D Simple as a pie. Thank you again, my friend @DMGregory

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .