Ignore Layer Collision
-Hi guys, I am trying to make a multiplayer game. I have particle effects to fire. I spawn particle effects from inside of player. I also have two layers named "LocalPlayer" and "RemotePlayer". But i have an issue.
am using "IgnoreLayerCollision" code to stop colliding the collision between Particle effect and Player so i can spawn particle effect from inside of player.
-Firstly, i stopped the collision between Local player and particle effect and then i stopped the collision between Remote player and particle effect.
-But i encountered an issue. The issue is this; After i built game, On built version, when i fire particle effect, it succesfully gets spawned from local player but on unity's side the local player is being remote player and it is not colliding the other players.
-The thing that i am trying to do is; particle effect won't collide the player it gets spawn but others. I hope you understand me when you watch the video that i am sharing with you. If you help me, i will be overjoyed. Thanks.
-https://www.youtube.com/watch?v=ZKyuTSkgW9I&feature=youtu.be
-This is the code i am using;
public void IgnoringCollision() { if (isLocalPlayer) { Physics.IgnoreLayerCollision(9, 12); } else { Physics.IgnoreLayerCollision(10, 12); } }
Answer by Okido · May 13, 2018 at 11:51 AM
Seems like it might be to do with the "islocalplayer" condition in the if statement? Have you tried removing that condition? Or removing the code altogether and unchecking their collision in Unity's Layer Collision Matrix?
(Edit > Project Settings > Physics)
If i remove if the code, particle effects will colide the player that spawn. I tried the layer collision matrix. It does same thing with the code i wrote.
In the Unity editor, just head to Edit, Project, Physics. Then the Physics $$anonymous$$anager will come up in the Inspector. Expand the "Layer Collision $$anonymous$$atrix" section, and you can see what collides with what. Uncheck anything that you don't want to collide (:
I've added an image to the answer to make it clearer - hope it helps!
Answer by CoolCosmos · May 13, 2018 at 12:36 PM
Sorry but that didn't help. :(
Ah, sorry to hear. I guess I'll eave it in case it helps anyone else, but I hope you figure it out. Let us know when you do!
Your answer
![](https://koobas.hobune.stream/wayback/20220612162553im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Can't make bullet ignore colisions 0 Answers
It is possible to filter and ignore collisions by a Layermask? 0 Answers
IgnoreCollision not working 0 Answers
Physics.IgnoreCollision between rigidebody2d+polygone collider 2d and edge collider 2d doesn't work? 1 Answer
No errors console but Physics2D.IgnoreCollision does not work 0 Answers